Import std.math.quat
Quat
struct
Public Struct Quat Implements Equatable, Printable
A rotation: x, y, and z are its axis times the sine of half its angle, and w the cosine of half of it. q * v turns v, and a * b turns by b, then by a. q and -q are the same rotation.
Examples
Local turn = Quat.FromAxisAngle(Vec3(0, 1, 0), Deg(90))
Expect(IsClose(turn * Vec3(1, 0, 0), Vec3(0, 0, -1)))
Local half = Slerp(Quat.Identity, turn, 0.5)
Expect(IsClose(Angle(Quat.Identity, half), Deg(45)))
Expect(IsClose(Inverse(turn) * (turn * Vec3(1, 2, 3)), Vec3(1, 2, 3)))-
Its axis's x times the sine of half its angle.
-
Its axis's y times the sine of half its angle.
-
Its axis's z times the sine of half its angle.
-
The cosine of half its angle.
-
No rotation.
-
The rotation by the
angle, in radians, about theaxis. A zeroaxisgives no rotation. -
The rotation by Euler angles in radians:
zabout Z, thenxabout X, thenyabout Y, as a camera's roll, pitch, and yaw. -
The rotation a rotation matrix makes, whose columns are the turned axes.
-
The shortest rotation that turns the direction from to the direction to, however small. Opposite ones turn half a turn about an axis at right angles to them, and a zero one gives no rotation.
-
The rotation that turns Forward, -Z, to
forward, with Up turned as near to up as it goes: how an object or camera at a place facesforward. A zeroforward, or an up along it, panics. -
The rotation as a matrix, whose columns are the turned axes.
-
The rotation as a Mat4 that moves nothing.
-
The axis, of length 1, and the angle in radians, from 0 to Tau, it turns about it. No rotation gives the X axis and 0.
-
The Euler angles in radians, as FromEuler takes them: x from -Pi / 2 to Pi / 2, and y and z from -Pi to Pi. Within about 0.02 degrees of x's quarter turn, where y and z turn about nearly one axis and Floats can't tell them apart, x is the quarter turn and z is 0.
-
The Euler angles in degrees, for editors, as ToEuler gives them in radians.
-
Its components, as "(0, 0, 0, 1)".
-
The rotation by
b, then bya. -
The vector turned by the rotation.
-
The same rotation, with every component's sign turned.
Report an issue with this page or with FutureBlitz on GitHub.