Skip to content

editor / turnDirection

Function: turnDirection() ​

turnDirection(angle): Vector

Defined in: math/turn-direction.ts:25

Direction (cos α, sin α) of an angle in degrees, exact at every quarter turn.

Formula: α = 90q + r, 0 ≤ r < 90; (cos r, sin r) turned q times by (x, y) ↦ (−y, x). Math.cos(π / 2) is 6.1e-17, not 0: computing the quarter turns as such keeps 0°, 90°, 180° and 270° exact. Negative zeros are made positive. In the SVG frame (y down) a positive angle is clockwise on screen.

Parameters ​

angle ​

number

integer number of degrees, any value

Returns ​

Vector

the unit vector of the angle

Kind ​

math

See ​

DERIV-turned-shape