Q

namespace Q
spatial/src/quat.ts:1

Members

approxEquals

approxEquals(a: Quat, b: Quat, epsilon: number) → boolean
aQuat
Undocumented
bQuat
Undocumented
epsilonnumber
Undocumented

basis

basis(q: Quat) → { forward: Vec3; right: Vec3; up: Vec3 }

Column-major 3x3 basis of the quaternion, for building render matrices.

qQuat
Undocumented

conjugate

conjugate(q: Quat) → Quat

Inverse of a unit quaternion.

qQuat
Undocumented

equals

equals(a: Quat, b: Quat) → boolean
aQuat
Undocumented
bQuat
Undocumented

fromAxisAngle

fromAxisAngle(axis: Vec3, angle: number) → Quat
axisVec3
Undocumented
anglenumber
Undocumented

fromBasis

fromBasis(x: Vec3, y: Vec3, z: Vec3) → Quat

Quaternion from an orthonormal basis, given as the images of +X, +Y and +Z.

Shepperd's method: pick the largest diagonal term first. The naive single-branch formula divides by a quantity that goes to zero for rotations near 180 degrees, which is exactly the case a surface frame on the far side of a planet hits.

xVec3
Undocumented
yVec3
Undocumented
zVec3
Undocumented

fromUnitVectors

fromUnitVectors(from: Vec3, to: Vec3) → Quat

Shortest rotation taking unit vector from to unit vector to.

fromVec3
Undocumented
toVec3
Undocumented

IDENTITY

IDENTITY: Quat

integrate

integrate(q: Quat, angularVelocity: Vec3, dt: number) → Quat

Integrate an orientation by a body-frame angular velocity over dt.

Exact rotation about the (constant over the step) angular velocity axis rather than the usual first-order q + 0.5*ω*q*dt: the first-order form denormalizes, and at time-warp the accumulated drift is visible within a few seconds of wall clock.

qQuat
Undocumented
angularVelocityVec3
Undocumented
dtnumber
Undocumented

multiply

multiply(a: Quat, b: Quat) → Quat

Hamilton product: a then b applied in a's frame, i.e. rotate by b∘a.

aQuat
Undocumented
bQuat
Undocumented

normalize

normalize(q: Quat) → Quat
qQuat
Undocumented

quat

quat(x: number, y: number, z: number, w: number) → Quat
xnumber
Undocumented
ynumber
Undocumented
znumber
Undocumented
wnumber
Undocumented

Quat

Quat: unknown

Unit quaternion, (x, y, z) vector part and w scalar part.

Orientations are quaternions everywhere in the simulation. Euler angles show up only at presentation boundaries: 6-DoF flight has no privileged axis, so any Euler convention gimbal-locks somewhere a player will actually fly.

rotate

rotate(q: Quat, v: Vec3) → Vec3

Rotate a vector from local axes into the quaternion's parent axes.

qQuat
Undocumented
vVec3
Undocumented

rotateInverse

rotateInverse(q: Quat, v: Vec3) → Vec3

Rotate a vector from parent axes into the quaternion's local axes.

qQuat
Undocumented
vVec3
Undocumented

slerp

slerp(a: Quat, b: Quat, t: number) → Quat
aQuat
Undocumented
bQuat
Undocumented
tnumber
Undocumented