Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Quaternion

Class used to store quaternion data

see

https://en.wikipedia.org/wiki/Quaternion

Hierarchy

  • Quaternion

Implements

Index

Constructors

constructor

  • new Quaternion(x?: number, y?: number, z?: number, w?: number): Quaternion
  • Creates a new Quaternion from the given floats

    Parameters

    • Default value x: number = 0

      defines the first component (0 by default)

    • Default value y: number = 0

      defines the second component (0 by default)

    • Default value z: number = 0

      defines the third component (0 by default)

    • Default value w: number = 1

      defines the fourth component (1.0 by default)

    Returns Quaternion

Properties

w

w: number

defines the fourth component (1.0 by default)

x

x: number

defines the first component (0 by default)

y

y: number

defines the second component (0 by default)

z

z: number

defines the third component (0 by default)

Methods

add

  • Adds two quaternions

    Parameters

    Returns Quaternion

    a new quaternion as the addition result of the given one and the current quaternion

addInPlace

asArray

  • asArray(): number[]
  • Copy the quaternion to an array

    Returns number[]

    a new array populated with 4 elements from the quaternion coordinates

clone

conjugate

conjugateInPlace

conjugateToRef

  • Conjugates (1-q) the current quaternion and stores the result in the given quaternion

    Parameters

    Returns Quaternion

    the current quaternion

copy

copyFrom

copyFromFloats

  • copyFromFloats(x: number, y: number, z: number, w: number): Quaternion
  • Updates the current quaternion with the given float coordinates

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns Quaternion

    the updated current quaternion

equals

  • Check if two quaternions are equals

    Parameters

    • otherQuaternion: Quaternion

      defines the second operand

    Returns boolean

    true if the current quaternion and the given one coordinates are strictly equals

fromRotationMatrix

  • Updates the current quaternion from the given rotation matrix values

    Parameters

    • matrix: Matrix

      defines the source matrix

    Returns Quaternion

    the current updated quaternion

getClassName

  • getClassName(): string
  • Gets the class name of the quaternion

    Returns string

    the string "Quaternion"

getHashCode

  • getHashCode(): number
  • Gets a hash code for this quaternion

    Returns number

    the quaternion hash code

length

  • length(): number
  • Gets length of current quaternion

    Returns number

    the quaternion length (float)

multiply

  • Multiplies two quaternions

    Parameters

    Returns Quaternion

    a new quaternion set as the multiplication result of the current one with the given one "q1"

multiplyInPlace

  • Updates the current quaternion with the multiplication of itself with the given one "q1"

    Parameters

    Returns Quaternion

    the currentupdated quaternion

multiplyToRef

  • Sets the given "result" as the the multiplication result of the current one with the given one "q1"

    Parameters

    Returns Quaternion

    the current quaternion

normalize

scale

  • Multiplies the current quaternion by a scale factor

    Parameters

    • value: number

      defines the scale factor

    Returns Quaternion

    a new quaternion set by multiplying the current quaternion coordinates by the float "scale"

scaleAndAddToRef

  • Scale the current quaternion values by a factor and add the result to a given quaternion

    Parameters

    • scale: number

      defines the scale factor

    • result: Quaternion

      defines the Quaternion object where to store the result

    Returns Quaternion

    the unmodified current quaternion

scaleInPlace

  • Multiplies in place the current quaternion by a scale factor

    Parameters

    • value: number

      defines the scale factor

    Returns Quaternion

    the current modified quaternion

scaleToRef

  • Scale the current quaternion values by a factor and stores the result to a given quaternion

    Parameters

    • scale: number

      defines the scale factor

    • result: Quaternion

      defines the Quaternion object where to store the result

    Returns Quaternion

    the unmodified current quaternion

set

  • set(x: number, y: number, z: number, w: number): Quaternion
  • Updates the current quaternion from the given float coordinates

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns Quaternion

    the updated current quaternion

subtract

  • Subtract two quaternions

    Parameters

    Returns Quaternion

    a new quaternion as the subtraction result of the given one from the current one

toEulerAngles

  • toEulerAngles(order?: string): Vector3
  • Returns a new Vector3 set with the Euler angles translated from the current quaternion

    Parameters

    • Default value order: string = "YZX"

      is a reserved parameter and is ignore for now

    Returns Vector3

    a new Vector3 containing the Euler angles

toEulerAnglesToRef

  • Sets the given vector3 "result" with the Euler angles translated from the current quaternion

    Parameters

    • result: Vector3

      defines the vector which will be filled with the Euler angles

    • Default value order: string = "YZX"

      is a reserved parameter and is ignore for now

    Returns Quaternion

    the current unchanged quaternion

toJSON

  • Returns a JSON representation of this quaternion. This is necessary due to the way Actors detect changes on components like the actor's transform. They do this by adding properties for observation, and we don't want these properties serialized.

    Returns QuaternionLike

toRotationMatrix

  • Updates the given rotation matrix with the current quaternion values

    Parameters

    • result: Matrix

      defines the target matrix

    Returns Quaternion

    the current unchanged quaternion

toString

  • toString(): string
  • Gets a string representation for the current quaternion

    Returns string

    a string with the Quaternion coordinates

Static AreClose

  • Checks if the two quaternions are close to each other

    Parameters

    • quat0: Quaternion

      defines the first quaternion to check

    • quat1: Quaternion

      defines the second quaternion to check

    Returns boolean

    true if the two quaternions are close to each other

Static Dot

  • Returns the dot product (float) between the quaternions "left" and "right"

    Parameters

    Returns number

    the dot product

Static FromArray

  • FromArray(array: ArrayLike<number>, offset?: number): Quaternion
  • Creates a new quaternion from data stored into an array

    Parameters

    • array: ArrayLike<number>

      defines the data source

    • Optional offset: number

      defines the offset in the source array where the data starts

    Returns Quaternion

    a new quaternion

Static FromEulerAngles

  • FromEulerAngles(x: number, y: number, z: number): Quaternion
  • Create a quaternion from Euler rotation angles

    Parameters

    • x: number

      Pitch

    • y: number

      Yaw

    • z: number

      Roll

    Returns Quaternion

    the new Quaternion

Static FromEulerAnglesToRef

  • Updates a quaternion from Euler rotation angles

    Parameters

    • x: number

      Pitch

    • y: number

      Yaw

    • z: number

      Roll

    • result: Quaternion

      the quaternion to store the result

    Returns Quaternion

    the updated quaternion

Static FromEulerVector

Static FromEulerVectorToRef

  • Updates a quaternion from Euler rotation vector

    Parameters

    • vec: Vector3

      the Euler vector (x Pitch, y Yaw, z Roll)

    • result: Quaternion

      the quaternion to store the result

    Returns Quaternion

    the updated quaternion

Static FromRotationMatrix

  • Creates a new quaternion from a rotation matrix

    Parameters

    • matrix: Matrix

      defines the source matrix

    Returns Quaternion

    a new quaternion created from the given rotation matrix values

Static FromRotationMatrixToRef

  • Updates the given quaternion with the given rotation matrix values

    Parameters

    • matrix: Matrix

      defines the source matrix

    • result: Quaternion

      defines the target quaternion

    Returns void

Static Hermite

  • Interpolate between two quaternions using Hermite interpolation

    Parameters

    • value1: Quaternion

      defines first quaternion

    • tangent1: Quaternion

      defines the incoming tangent

    • value2: Quaternion

      defines second quaternion

    • tangent2: Quaternion

      defines the outgoing tangent

    • amount: number

      defines the target quaternion

    Returns Quaternion

    the new interpolated quaternion

Static Identity

Static Inverse

Static InverseToRef

Static IsIdentity

  • Gets a boolean indicating if the given quaternion is identity

    Parameters

    • quaternion: Quaternion

      defines the quaternion to check

    Returns boolean

    true if the quaternion is identity

Static LookAt

  • Calculates a rotation to face the to point from the from point.

    Parameters

    • from: Vector3

      The location of the viewpoint.

    • to: Vector3

      The location to face toward.

    • Default value offset: Vector3 = Vector3.Zero()

      (Optional) Offset yaw, pitch, roll to add.

    Returns Quaternion

Static RotationAlphaBetaGamma

  • RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion
  • Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation

    Parameters

    • alpha: number

      defines the rotation around first axis

    • beta: number

      defines the rotation around second axis

    • gamma: number

      defines the rotation around third axis

    Returns Quaternion

    the new quaternion

Static RotationAlphaBetaGammaToRef

  • RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void
  • Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion

    Parameters

    • alpha: number

      defines the rotation around first axis

    • beta: number

      defines the rotation around second axis

    • gamma: number

      defines the rotation around third axis

    • result: Quaternion

      defines the target quaternion

    Returns void

Static RotationAxis

  • Creates a quaternion from a rotation around an axis

    Parameters

    • axis: Vector3

      defines the axis to use

    • angle: number

      defines the angle to use

    Returns Quaternion

    a new quaternion created from the given axis (Vector3) and angle in radians (float)

Static RotationAxisToRef

  • Creates a rotation around an axis and stores it into the given quaternion

    Parameters

    • axis: Vector3

      defines the axis to use

    • angle: number

      defines the angle to use

    • result: Quaternion

      defines the target quaternion

    Returns Quaternion

    the target quaternion

Static RotationQuaternionFromAxis

  • Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)

    Parameters

    • axis1: Vector3

      defines the first axis

    • axis2: Vector3

      defines the second axis

    • axis3: Vector3

      defines the third axis

    Returns Quaternion

    the new quaternion

Static RotationQuaternionFromAxisToRef

  • Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion

    Parameters

    • axis1: Vector3

      defines the first axis

    • axis2: Vector3

      defines the second axis

    • axis3: Vector3

      defines the third axis

    • ref: Quaternion

      defines the target quaternion

    Returns void

Static RotationYawPitchRoll

  • RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion
  • Creates a new quaternion from the given Euler float angles (y, x, z)

    Parameters

    • yaw: number

      defines the rotation around Y axis

    • pitch: number

      defines the rotation around X axis

    • roll: number

      defines the rotation around Z axis

    Returns Quaternion

    the new quaternion

Static RotationYawPitchRollToRef

  • RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void
  • Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion

    Parameters

    • yaw: number

      defines the rotation around Y axis

    • pitch: number

      defines the rotation around X axis

    • roll: number

      defines the rotation around Z axis

    • result: Quaternion

      defines the target quaternion

    Returns void

Static Slerp

  • Interpolates between two quaternions

    Parameters

    • left: Quaternion

      defines first quaternion

    • right: Quaternion

      defines second quaternion

    • amount: number

      defines the gradient to use

    Returns Quaternion

    the new interpolated quaternion

Static SlerpToRef

  • Interpolates between two quaternions and stores it into a target quaternion

    Parameters

    • left: Quaternion

      defines first quaternion

    • right: Quaternion

      defines second quaternion

    • amount: number

      defines the gradient to use

    • result: Quaternion

      defines the target quaternion

    Returns void

Static Zero