Quat

From Crumbled World Wiki
Revision as of 13:37, 5 July 2025 by Anders (talk | contribs) (Created page with "{{:QuatExampleCode}} ==Constructor== {| class="wikitable" !|function !|description |- |Quat(float x, float y, float z, float w) | |- |Quat(Vec3 axis, float degrees) | |- |Quat() | |- |} ==Functions== {| class="wikitable" !|return !|function !|description |- | |createFromRotationMatrix(Matrix mat) |. |- | |createMatrix(Matrix mat) |. |- | |reset() |Clear quat. |...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

QuatExampleCode

Constructor

function description
Quat(float x, float y, float z, float w)
Quat(Vec3 axis, float degrees)
Quat()

Functions

return function description
createFromRotationMatrix(Matrix mat) .
createMatrix(Matrix mat) .
reset() Clear quat.
invert() invert quat.
bool isIdentity() Is identity
dot(Quat quat)
fromEuler(float x, float y, float z) Create Quat from rotation around axis in radians.
Matrix getMatrix() get matrix.
Vec3 toEuler() get rotaion in radians and return.
normalize() Normalize axis scale so that only rotation remains.
slerp(Quat a, Quat b, float t) Creates a value for this Quat from spherical linear interpolation

t is the interpolation value from 0 to 1

slerp(Quat a, Quat b, float w) linearly interpolate each component, then normalize the Quat

Unlike spherical interpolation, this does not rotate at a constant velocity, although that's not necessarily a bad thing

aimZAxis(Vec3 p1, Vec3 p2) set quat to have at vec along the p1, p2 line

Operators

return function description
Quat Quat * float
Quat Quat * Quat
Quat Quat + Quat
Quat Quat - Quat
bool Quat == Quat