# Vertice operations. # **Vertice** is a utility class to help with vertice operations. A vertice # is implemented as a 2-element array. Element 0 is *x* and element 1 is *y*. # Translate a vertice from an origin point using rotation and scale. export translate = (v, origin, rotation = 0, scale = 1) -> difference = [v[0] - origin[0], v[1] - origin[1]] magnitude = scale * Math.sqrt( difference[0] * difference[0] + difference[1] * difference[1] ) rotation += Math.atan2 difference[1], difference[0] return [ origin[0] + Math.cos(rotation) * magnitude origin[1] + Math.sin(rotation) * magnitude ]