Namespace trigo
Trigo module provides some math stuff for moving objects in a direction or following a round path.
Defined in: trigo.js.
Method Summary
translate(p1, a, d)
Translates a point by a vector defined by angle and distance. This does not return a value but rather modifies the x and y values of p1.
translateX(x1, a, d)
Translates an x component of a coordinate by a vector defined by angle and distance. This returns its component translation.
translateY(y1, a, d)
Translates a y component of a coordinate by a vector defined by angle and distance. This returns its component translation.
Method Detail
trigo.addAngle(a, add)
Adds two angles together (radians).
Parameters:
{Float} | a | Base angle. |
{Float} | add | The angle you're adding to the base angle. |
Returns:
The resultant angle, always between 0 and 2*pi. |
trigo.getAngle(p1, p2, transl)
Calculates the angle between two points.
Parameters:
{Object} | p1 | This is an object containing x and y params for the first point. |
{Object} | p2 | This is an object containing x and y params for the second point. |
{Float} | transl | (Optional) Adds an angle (in radians) to the result. Defaults to 0. |
Returns:
The angle between points p1 and p2, plus transl. |
trigo.getDistance(p1, p2)
Gets the distance between two points.
Parameters:
{Object} | p1 | This is an object containing x and y params for the first point. |
{Object} | p2 | This is an object containing x and y params for the second point. |
Returns:
The distance between p1 and p2. |
trigo.translate(p1, a, d)
Translates a point by a vector defined by angle and distance. This does not return a value but rather modifies the x and y values of p1.
Parameters:
{Object} | p1 | This is an object containing x and y params for the point. |
{Float} | a | The angle of translation (rad). |
{Float} | d | The distance of translation. |