Math
Math Functions
- Angle Math Functions
These functions convert between angles and rectangular components. All angles are measured in degrees. Positive angles indicate counter-clockwise rotation. A heading angle of 0 degrees points straight right (east) along the positive X axis.
convertToComponents
convertToComponents
Converts an angle and length into rectangular vector components.
angle
*
number
-
the angle of counter-clockwise rotation, in degrees, where zero degrees lies along the positive X axis
length
*
number
-
the length of the desired vector
Returns
array
An array [x, y]
containing the two vector components
convertToAngle
convertToAngle
Converts rectangular vector components into an angle in degrees.
x
*
number
-
the x coordinate of the vector
y
*
number
-
the y coordinate of the vector
Returns
number
The heading angle defined by the given vector, in degrees.
- Other Math Functions
pointInPolygon
pointInPolygon
Draws a single pixel.
x
*
number
-
the x coordinate of the given point
y
*
number
-
the y coordinate of the given point
polygon
*
array
-
The polygon, as an array of [x, y]
subarrays
Returns
boolean
true
if the point is inside the polygon, and false
otherwise.
Last updated