Import std.math.quat
std.math.quat
Quat: a rotation, as a unit quaternion of Floats, x, y, z, and w. Angles are radians, and the rotations turn counterclockwise about an axis that points at the viewer, by the right-hand rule. Euler angles go in Y, X, Z order, as a camera's yaw, pitch, and roll: Z first, then X, then Y.
std/math/quat.fb
Types
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.
-
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 text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString. -
The rotation by
b, then bya. -
The vector turned by the rotation.
-
The same rotation, with every component's sign turned.
Functions
Dot
function
Public Function Dot(a: Quat, b: Quat): Float
The sum of the products of the components: the cosine of half the angle between two rotations.
Length
function
Public Function Length(q: Quat): Float
The quaternion's length, which a rotation's is 1, worked out in Doubles, as a Vec4's is.
Normalize
function
Public Function Normalize(q: Quat): Quat
The quaternion scaled to length 1, as rounding over many rotations wears it, worked out in Doubles, as a Vec4's is. A zero one gives no rotation.
Inverse
function
Public Function Inverse(q: Quat): Quat
The opposite rotation, which undoes it: for a unit quaternion, as a rotation is, its conjugate.
Lerp
function
Public Function Lerp(a: Quat, b: Quat, t: Float): Quat
The rotation t of the way from a to b, the short way around, as a straight line between
them scaled to length 1: quicker than Slerp, and nearly as smooth for angles that aren't large.
Slerp
function
Public Function Slerp(a: Quat, b: Quat, t: Float): Quat
The rotation t of the way from a to b, the short way around, at an even speed.
Angle
function
Public Function Angle(a: Quat, b: Quat): Float
The angle in radians, from 0 to Pi, of the rotation from a to b, from its half angle's sine
and cosine, which keep small angles exact.
IsClose
function
Public Function IsClose(a: Quat, b: Quat): Bool
Whether the two are close as rotations, as IsClose tells for each component, with q and -q the same rotation.
Report an issue with this page or with FutureBlitz on GitHub.