Quat

Source: Quat.ts:21

A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.


Constructor

new Quat(x?: Number, y?: Number, z?: Number, w?: Number): Quat

Parameters

  • x (Number, optional, default: "0.0") — The X component.
  • y (Number, optional, default: "0.0") — The Y component.
  • z (Number, optional, default: "0.0") — The Z component.
  • w (Number, optional, default: "0.0") — The W component.

Instance Methods

isZero(): boolean

Returns true if the components are zero.

Returns

  • boolean

isNaN(): boolean

Returns true if a component is NaN.

Returns

  • boolean

clear(): Quat

Clear Quat. Sets zeroes.

Returns

set(x?: Number, y?: Number, z?: Number, w?: Number): Quat

Sets Quat values.

Parameters

  • x (Number, optional, default: "0.0") — The X component.
  • y (Number, optional, default: "0.0") — The Y component.
  • z (Number, optional, default: "0.0") — The Z component.
  • w (Number, optional, default: "0.0") — The W component.

Returns

copy(q: Quat): Quat

Copy Quat values.

Parameters

  • q (Quat) — Copy Quat.

Returns

setIdentity(): Quat

Set current Quat instance to identity Quat.

Returns

clone(): Quat

Duplicates a Quat instance.

Returns

add(q: Quat): Quat

Computes the componentwise sum of two Quats.

Parameters

  • q (Quat) — Quat to add.

Returns

addRes(q: Quat, res: Quat): Quat

Computes the componentwise sum of two Quats.

Parameters

  • q (Quat) — Quat to add.
  • res (Quat) — Output quaternion.

Returns

  • Quat — Result quaternion.

sub(q: Quat): Quat

Computes the componentwise difference of two Quats.

Parameters

  • q (Quat) — Quat to subtract.

Returns

scaleTo(scale: Number): Quat

Multiplies the provided Quat componentwise by the provided scalar.

Parameters

  • scale (Number) — The scalar to multiply with.

Returns

scale(scale: Number): Quat

Multiplies the provided Quat componentwise.

Parameters

  • scale (Number) — The scalar to multiply with.

Returns

toVec(): Array.<number>

Converts Quat values to array.

Returns

  • Array.<number>

setLookRotation(forward: Vec3, up: Vec3): Quat

Sets rotation with the given heading and up vectors.

Parameters

  • forward (Vec3) — Heading target coordinates.
  • up (Vec3) — Up vector.

Returns

setFromSphericalCoords( lat: number, lon: number, angle: number, ): Quat

Sets current quaternion by spherical coordinates.

Parameters

  • lat (number) — Latitude.
  • lon (number) — Longitude.
  • angle (number) — Angle in radians.

Returns

getSphericalCoords(): Object

Gets spherical coordinates.

Returns

  • Object — Returns object with latitude, longitude and alpha.

setFromAxisAngle(axis: Vec3, angle: number): Quat

Sets current Quat representing a rotation around an axis.

Parameters

  • axis (Vec3) — The axis of rotation.
  • angle (number) — The angle in radians to rotate around the axis.

Returns

getAxisAngle(): QuatAxisAngle

Returns axis and angle of the current Quat.

Returns

_sinPitch(): number

protected
Quat.ts:539

Sine of the pitch angle - the shared term of the euler decomposition below.

Returns

  • number

_atEulerPole(): boolean

protected
Quat.ts:549

True when the rotation looks straight up or down (gimbal lock): the getters then return roll 0 and put the whole turn into yaw.

Returns

  • boolean

setFromEulerAngles( pitch: number, yaw: number, roll: number, ): Quat

Sets current Quat by Euler's angles.

Parameters

  • pitch (number) — Pitch angle in degrees.
  • yaw (number) — Yaw angle in degrees.
  • roll (number) — Roll angle in degrees.

Returns

getEulerAngles(): Object

Returns Euler's angles of the current Quat.

Returns

  • Object

setFromMatrix4(mx: Mat4): Quat

Computes a Quat from the provided 4x4 matrix instance.

Parameters

  • mx (Mat4) — The rotation matrix.

Returns

getMat4(out?: Mat4): Mat4

Converts current Quat to the rotation 4x4 matrix.

Parameters

  • out (Mat4, optional) — Output matrix.

Returns

getMat3(): Mat3

Converts current Quat to the rotation 3x3 matrix.

Returns

  • TODO:
    • NOT TESTED

mulVec3(v: Vec3): Vec3

Returns quaternion and vector production.

Parameters

  • v (Vec3) — 3d Vector.

Returns

mulVec3Res(v: Vec3, res: Vec3): Vec3

Returns quaternion and vector production.

Parameters

  • v (Vec3) — 3d Vector.
  • res (Vec3) — result output vector.

Returns

mul(q: Quat): Quat

Computes the product of two Quats.

Parameters

  • q (Quat) — Quat to multiply.

Returns

mulRes(q: Quat, res: Quat): Quat

Computes the product of two Quats.

Parameters

  • q (Quat) — Quat to multiply.
  • res (Quat) — Output quaternion.

Returns

  • Quat — Result quaternion.

mulA(q: Quat): Quat

Computes the product of two Quats.

Parameters

  • q (Quat) — Quat to multiply.

Returns

conjugate(): Quat

Returns the conjugate of the current quaternion.

Returns

inverse(): Quat

Computes the inverse of the Quat.

Returns

magnitude(): number

Computes a magnitude of the Quat.

Returns

  • number

magnitude2(): number

Computes a squared magnitude of the Quat.

Returns

  • number

dot(q: Quat): number

Computes the dot (scalar) product of two Quats.

Parameters

  • q (Quat) — Second quaternion.

Returns

  • number

normalize(): Quat

Current Quat normalization.

Returns

isEqual(q: Quat): Boolean

Compares two Quats.

Parameters

  • q (Quat) — Second quaternion.

Returns

  • Boolean

slerp(b: Quat, t: number): Quat

Performs a spherical linear interpolation between two Quats.

Parameters

  • b (Quat) — The end rotation Quat.
  • t (number) — interpolation amount between the two Quats.

Returns

Static Methods

xRotation(a: number): Quat

Returns a Quat represents rotation around X axis.

Parameters

  • a (number) — The angle in radians to rotate around the axis.

Returns

yRotation(a: number): Quat

Returns a Quat represents rotation around Y axis.

Parameters

  • a (number) — The angle in radians to rotate around the axis.

Returns

zRotation(a: number): Quat

Returns a Quat represents rotation around Z axis.

Parameters

  • a (number) — The angle in radians to rotate around the axis.

Returns

axisAngleToQuat(axis: Vec3, angle?: number): Quat

Computes a Quat representing a rotation around an axis.

Parameters

  • axis (Vec3) — The axis of rotation.
  • angle (number, optional, default: "0.0") — The angle in radians to rotate around the axis.

Returns

getLookRotation(forward: Vec3, up: Vec3): Quat

Computes a rotation from the given heading and up vector.

Parameters

  • forward (Vec3) — Heading target coordinates.
  • up (Vec3) — Up vector.

Returns

getLookAtSourceDest(sourcePoint: Vec3, destPoint: Vec3): Quat

Computes a Quat from source point heading to the destination point.

Parameters

  • sourcePoint (Vec3) — Source coordinate.
  • destPoint (Vec3) — Destination coordinate.

Returns

getRotationBetweenVectors(u: Vec3, v: Vec3): Quat

Computes rotation between two vectors.

Parameters

  • u (Vec3) — First vector.
  • v (Vec3) — Second vector.

Returns

getRotationBetweenVectorsRes(u: Vec3, v: Vec3, res: Quat): Quat

Computes rotation between two vectors.

Parameters

  • u (Vec3) — First vector.
  • v (Vec3) — Second vector.
  • res (Quat) — Output quaternion.

Returns

getRotationBetweenVectorsUp( source: Vec3, dest: Vec3, up: Vec3, ): Quat

Computes rotation between two vectors. Uses the up vector when vectors are exactly opposite. Returns identity when vectors are exactly equal.

Parameters

  • source (Vec3) — First vector.
  • dest (Vec3) — Second vector.
  • up (Vec3) — Up vector.

Returns

Other

IDENTITY: Quat

Identity Quat.