Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace quat

Index

Functions

Const add

  • add(out: vec4, a: ReadonlyVec4, b: ReadonlyVec4): vec4
  • Adds two quat's

    function

    Parameters

    • out: vec4

      the receiving quaternion

    • a: ReadonlyVec4

      the first operand

    • b: ReadonlyVec4

      the second operand

    Returns vec4

    out

calculateW

  • calculateW(out: quat, a: ReadonlyQuat): quat
  • Calculates the W component of a quat from the X, Y, and Z components. Assumes that quaternion is 1 unit in length. Any existing W component will be ignored.

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate W component of

    Returns quat

    out

Const clone

  • clone(a: ReadonlyVec4): vec4
  • Creates a new quat initialized with values from an existing quaternion

    function

    Parameters

    • a: ReadonlyVec4

      quaternion to clone

    Returns vec4

    a new quaternion

conjugate

  • conjugate(out: quat, a: ReadonlyQuat): quat
  • Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate conjugate of

    Returns quat

    out

Const copy

  • copy(out: vec4, a: ReadonlyVec4): vec4
  • Copy the values from one quat to another

    function

    Parameters

    • out: vec4

      the receiving quaternion

    • a: ReadonlyVec4

      the source quaternion

    Returns vec4

    out

create

  • Creates a new identity quat

    Returns quat

    a new quaternion

Const dot

  • dot(a: ReadonlyVec4, b: ReadonlyVec4): number
  • Calculates the dot product of two quat's

    function

    Parameters

    • a: ReadonlyVec4

      the first operand

    • b: ReadonlyVec4

      the second operand

    Returns number

    dot product of a and b

Const equals

  • equals(a: ReadonlyVec4, b: ReadonlyVec4): boolean
  • Returns whether or not the quaternions have approximately the same elements in the same position.

    Parameters

    • a: ReadonlyVec4

      The first vector.

    • b: ReadonlyVec4

      The second vector.

    Returns boolean

    True if the vectors are equal, false otherwise.

Const exactEquals

  • exactEquals(a: ReadonlyVec4, b: ReadonlyVec4): boolean
  • Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)

    Parameters

    • a: ReadonlyVec4

      The first quaternion.

    • b: ReadonlyVec4

      The second quaternion.

    Returns boolean

    True if the vectors are equal, false otherwise.

exp

  • Calculate the exponential of a unit quaternion.

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate the exponential of

    Returns quat

    out

fromEuler

  • fromEuler(out: quat, x: any, y: any, z: any): quat
  • Creates a quaternion from the given euler angle x, y, z.

    function

    Parameters

    • out: quat

      the receiving quaternion

    • x: any
    • y: any
    • z: any

    Returns quat

    out

fromMat3

  • fromMat3(out: quat, m: ReadonlyMat3): quat
  • Creates a quaternion from the given 3x3 rotation matrix.

    NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.

    function

    Parameters

    • out: quat

      the receiving quaternion

    • m: ReadonlyMat3

      rotation matrix

    Returns quat

    out

Const fromValues

  • fromValues(x: number, y: number, z: number, w: number): vec4
  • Creates a new quat initialized with the given values

    function

    Parameters

    • x: number

      X component

    • y: number

      Y component

    • z: number

      Z component

    • w: number

      W component

    Returns vec4

    a new quaternion

getAngle

  • getAngle(a: ReadonlyQuat, b: ReadonlyQuat): number
  • Gets the angular distance between two unit quaternions

    Parameters

    • a: ReadonlyQuat

      Origin unit quaternion

    • b: ReadonlyQuat

      Destination unit quaternion

    Returns number

    Angle, in radians, between the two quaternions

getAxisAngle

  • getAxisAngle(out_axis: vec3, q: ReadonlyQuat): number
  • Gets the rotation axis and angle for a given quaternion. If a quaternion is created with setAxisAngle, this method will return the same values as providied in the original parameter list OR functionally equivalent values. Example: The quaternion formed by axis [0, 0, 1] and angle -90 is the same as the quaternion formed by [0, 0, 1] and 270. This method favors the latter.

    Parameters

    • out_axis: vec3

      Vector receiving the axis of rotation

    • q: ReadonlyQuat

      Quaternion to be decomposed

    Returns number

    Angle, in radians, of the rotation

identity

  • Set a quat to the identity quaternion

    Parameters

    • out: quat

      the receiving quaternion

    Returns quat

    out

invert

  • invert(out: quat, a: ReadonlyQuat): quat
  • Calculates the inverse of a quat

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate inverse of

    Returns quat

    out

Const len

  • len(a: ReadonlyVec4): number
  • Alias for quat.length

    function

    Parameters

    • a: ReadonlyVec4

    Returns number

Const length

  • length(a: ReadonlyVec4): number
  • Calculates the length of a quat

    Parameters

    • a: ReadonlyVec4

      vector to calculate length of

    Returns number

    length of a

Const lerp

  • lerp(out: vec4, a: ReadonlyVec4, b: ReadonlyVec4, t: number): vec4
  • Performs a linear interpolation between two quat's

    function

    Parameters

    • out: vec4

      the receiving quaternion

    • a: ReadonlyVec4

      the first operand

    • b: ReadonlyVec4

      the second operand

    • t: number

      interpolation amount, in the range [0-1], between the two inputs

    Returns vec4

    out

ln

  • Calculate the natural logarithm of a unit quaternion.

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate the exponential of

    Returns quat

    out

mul

  • mul(out: quat, a: ReadonlyQuat, b: ReadonlyQuat): quat
  • Multiplies two quat's

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      the first operand

    • b: ReadonlyQuat

      the second operand

    Returns quat

    out

multiply

  • multiply(out: quat, a: ReadonlyQuat, b: ReadonlyQuat): quat
  • Multiplies two quat's

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      the first operand

    • b: ReadonlyQuat

      the second operand

    Returns quat

    out

Const normalize

  • normalize(out: vec4, a: ReadonlyVec4): vec4
  • Normalize a quat

    function

    Parameters

    • out: vec4

      the receiving quaternion

    • a: ReadonlyVec4

      quaternion to normalize

    Returns vec4

    out

pow

  • pow(out: quat, a: ReadonlyQuat, b: number): quat
  • Calculate the scalar power of a unit quaternion.

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      quat to calculate the exponential of

    • b: number

      amount to scale the quaternion by

    Returns quat

    out

random

  • Generates a random unit quaternion

    Parameters

    • out: quat

      the receiving quaternion

    Returns quat

    out

rotateX

  • rotateX(out: quat, a: ReadonlyQuat, rad: number): quat
  • Rotates a quaternion by the given angle about the X axis

    Parameters

    • out: quat

      quat receiving operation result

    • a: ReadonlyQuat

      quat to rotate

    • rad: number

      angle (in radians) to rotate

    Returns quat

    out

rotateY

  • rotateY(out: quat, a: ReadonlyQuat, rad: number): quat
  • Rotates a quaternion by the given angle about the Y axis

    Parameters

    • out: quat

      quat receiving operation result

    • a: ReadonlyQuat

      quat to rotate

    • rad: number

      angle (in radians) to rotate

    Returns quat

    out

rotateZ

  • rotateZ(out: quat, a: ReadonlyQuat, rad: number): quat
  • Rotates a quaternion by the given angle about the Z axis

    Parameters

    • out: quat

      quat receiving operation result

    • a: ReadonlyQuat

      quat to rotate

    • rad: number

      angle (in radians) to rotate

    Returns quat

    out

rotationTo

  • rotationTo(out: any, a: any, b: any): any
  • Parameters

    • out: any
    • a: any
    • b: any

    Returns any

Const scale

  • scale(out: vec4, a: ReadonlyVec4, b: number): vec4
  • Scales a quat by a scalar number

    function

    Parameters

    • out: vec4

      the receiving vector

    • a: ReadonlyVec4

      the vector to scale

    • b: number

      amount to scale the vector by

    Returns vec4

    out

Const set

  • set(out: vec4, x: number, y: number, z: number, w: number): vec4
  • Set the components of a quat to the given values

    function

    Parameters

    • out: vec4

      the receiving quaternion

    • x: number

      X component

    • y: number

      Y component

    • z: number

      Z component

    • w: number

      W component

    Returns vec4

    out

setAxes

  • setAxes(out: any, view: any, right: any, up: any): vec4
  • Parameters

    • out: any
    • view: any
    • right: any
    • up: any

    Returns vec4

setAxisAngle

  • setAxisAngle(out: quat, axis: ReadonlyVec3, rad: number): quat
  • Sets a quat from the given angle and rotation axis, then returns it.

    Parameters

    • out: quat

      the receiving quaternion

    • axis: ReadonlyVec3

      the axis around which to rotate

    • rad: number

      the angle in radians

    Returns quat

    out

slerp

  • slerp(out: quat, a: ReadonlyQuat, b: ReadonlyQuat, t: number): quat
  • Performs a spherical linear interpolation between two quat

    Parameters

    • out: quat

      the receiving quaternion

    • a: ReadonlyQuat

      the first operand

    • b: ReadonlyQuat

      the second operand

    • t: number

      interpolation amount, in the range [0-1], between the two inputs

    Returns quat

    out

sqlerp

  • sqlerp(out: any, a: any, b: any, c: any, d: any, t: any): any
  • Parameters

    • out: any
    • a: any
    • b: any
    • c: any
    • d: any
    • t: any

    Returns any

Const sqrLen

  • sqrLen(a: ReadonlyVec4): number
  • Alias for quat.squaredLength

    function

    Parameters

    • a: ReadonlyVec4

    Returns number

Const squaredLength

  • squaredLength(a: ReadonlyVec4): number
  • Calculates the squared length of a quat

    function

    Parameters

    • a: ReadonlyVec4

      vector to calculate squared length of

    Returns number

    squared length of a

str

  • str(a: ReadonlyQuat): string
  • Returns a string representation of a quatenion

    Parameters

    • a: ReadonlyQuat

      vector to represent as a string

    Returns string

    string representation of the vector