Math module

rotate

procedure · 2 overloadsSource

Rotates a vector or a matrix.

ExampleOpen in playground ↗
v := rotate(xy(1, 0), PI / 2);
assert(abs(v.x) < 0.0001 && abs(v.y - 1) < 0.0001);

q: Quaternion;
set_from_axis_and_angle(*q, xyz(0, 0, 1), PI);
w := rotate(xyz(1, 0, 0), q);
assert(abs(w.x + 1) < 0.0001 && abs(w.y) < 0.0001);
rotate :: (v: Vector2, theta: float) -> Vector2

Rotates v counterclockwise about the origin.

Parameters

v: Vector2
the vector to rotate.
theta: float
the angle in radians.

Returns

rotate :: (v: *Vector2, theta: float)

Rotates *v counterclockwise about the origin, in place.

Parameters

v: *Vector2
the vector to rotate.
theta: float
the angle in radians.

See also