Rotates a vector or a matrix.
rotate(v: Vector2, theta)turns the vector counter-clockwise bythetaradians; a pointer rotates in place.rotate(v: Vector3, q)applies a unit quaternionq; a pointer rotates in place.rotate(m: Matrix3 or Matrix4, q)returnsm * rotation_matrix(q), so the rotation is applied beforem's own transform.
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.