Math module

set_from_axis_and_angle

procedure · 2 overloadsSource

Sets a quaternion to the rotation by theta radians about v (or x, y, z), counter-clockwise looking down the axis. The axis must be unit length; it is not normalized here.

ExampleOpen in playground ↗
q: Quaternion;
set_from_axis_and_angle(*q, xyz(0, 0, 1), PI);
assert(abs(q.z - 1) < 0.0001 && abs(q.w) < 0.0001);
set_from_axis_and_angle(*q, 1, 0, 0, 0);
assert(q == Quaternion.{});
set_from_axis_and_angle :: (q: *Quaternion, v: Vector3, theta: float)

Sets *q to a rotation about an axis. The axis is not normalized, so pass a unit vector.

Parameters

q: *Quaternion
the quaternion to write.
v: Vector3
the rotation axis.
theta: float
the angle in radians.
set_from_axis_and_angle :: (
    q: *Quaternion,
    x: float,
    y: float,
    z: float,
    theta: float
)

Sets *q to a rotation about an axis. The axis is not normalized, so pass a unit vector.

Parameters

q: *Quaternion
the quaternion to write.
x: float
the x of the rotation axis.
y: float
the y of the rotation axis.
z: float
the z of the rotation axis.
theta: float
the angle in radians.

See also