Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Quat

quaternion

Hierarchy

Index

Constructors

constructor

  • newQuat(other: Quat): Quat
  • newQuat(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat

Properties

w

w: number

w component.

x

x: number

x component.

y

y: number

y component.

z

z: number

z component.

Static IDENTITY

IDENTITY: {} = Object.freeze(new Quat())

Type declaration

Methods

clone

equals

  • equals(other: Quat, epsilon?: number): boolean
  • Check whether the quaternion approximately equals another one

    Parameters

    • other: Quat

      Comparative quaternion

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true' when the components of the two quaternions are equal within the specified error range; otherwise, returnsfalse'.

getEulerAngles

length

  • length(): number

lengthSqr

  • lengthSqr(): number

lerp

  • lerp(to: Quat, ratio: number): this
  • Calculate the linear interpolation result between this quaternion and another one with given ratio

    Parameters

    • to: Quat

      The target quaternion

    • ratio: number

      The interpolation coefficient. The range is [0,1].

    Returns this

set

  • set(other: Quat): Quat
  • set(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat

slerp

  • slerp(to: Quat, ratio: number): this
  • Calculates the spherical interpolation result between this quaternion and another one with the given ratio

    Parameters

    • to: Quat

      The target quaternion

    • ratio: number

      The interpolation coefficient. The range is [0,1].

    Returns this

strictEquals

  • strictEquals(other: Quat): boolean
  • Check whether the current quaternion strictly equals other quaternion

    Parameters

    • other: Quat

      Comparative quaternion

    Returns boolean

    Returns true' when the components of the two quaternions are equal within the specified error range; otherwise, returnsfalse'.

toString

  • toString(): string

Static calculateW

  • calculateW<Out>(out: Out, a: Out): Out
  • Calculates the w component with xyz components, considering the given quaternion normalized

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns Out

Static clone

  • clone<Out>(a: Out): Quat

Static conjugate

  • conjugate<Out>(out: Out, a: Out): Out
  • Conjugating a quaternion, it's equivalent to the inverse of the unit quaternion, but more efficient

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns Out

Static copy

  • copy<Out, QuatLike>(out: Out, a: QuatLike): Out

Static dot

  • dot<Out>(a: Out, b: Out): number

Static equals

Static fromAngleZ

  • fromAngleZ<Out>(out: Out, z: number): Out
  • Calculates the quaternion with given 2D angle (0, 0, z).

    Type parameters

    Parameters

    • out: Out

      Output quaternion

    • z: number

      Angle to rotate around Z axis in degrees.

    Returns Out

Static fromArray

Static fromAxes

  • fromAxes<Out, VecLike>(out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out
  • Calculated the quaternion represents the given coordinates, considering all given vectors are normalized and mutually perpendicular

    Type parameters

    Parameters

    • out: Out
    • xAxis: VecLike
    • yAxis: VecLike
    • zAxis: VecLike

    Returns Out

Static fromAxisAngle

  • fromAxisAngle<Out, VecLike>(out: Out, axis: VecLike, rad: number): Out
  • Calculates the quaternion from a given rotary shaft and a radian rotation around it.

    Type parameters

    Parameters

    • out: Out
    • axis: VecLike
    • rad: number

    Returns Out

Static fromEuler

  • fromEuler<Out>(out: Out, x: number, y: number, z: number): Out
  • Calculates the quaternion with Euler angles, the rotation order is YZX

    Type parameters

    Parameters

    • out: Out
    • x: number
    • y: number
    • z: number

    Returns Out

Static fromMat3

  • fromMat3<Out>(out: Out, m: Mat3): Out
  • Calculates the quaternion with the three-dimensional transform matrix, considering no scale included in the matrix

    Type parameters

    Parameters

    Returns Out

Static fromViewUp

  • fromViewUp<Out, VecLike>(out: Out, view: VecLike, up?: Vec3): Out
  • Calculates the quaternion with the up direction and the direction of the viewport

    Type parameters

    Parameters

    • out: Out
    • view: VecLike

      The view direction, it`s must be normalized.

    • Optional up: Vec3

      The view up direction, it`s must be normalized, default value is (0, 1, 0).

    Returns Out

Static getAxisAngle

  • getAxisAngle<Out, VecLike>(outAxis: VecLike, q: Out): number
  • Gets the rotation axis and the arc of rotation from the quaternion

    Type parameters

    Parameters

    • outAxis: VecLike

      output axis

    • q: Out

      input quaternion

    Returns number

    radius of rotation

Static identity

  • identity<Out>(out: Out): Out

Static invert

  • invert<Out, QuatLike>(out: Out, a: QuatLike): Out

Static len

  • len<Out>(a: Out): number

Static lengthSqr

  • lengthSqr<Out>(a: Out): number

Static lerp

  • lerp<Out>(out: Out, a: Out, b: Out, t: number): Out
  • Element by element linear interpolation: A + t * (B - A)

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out
    • t: number

    Returns Out

Static multiply

  • multiply<Out, QuatLike_1, QuatLike_2>(out: Out, a: QuatLike_1, b: QuatLike_2): Out

Static multiplyScalar

  • multiplyScalar<Out>(out: Out, a: Out, b: number): Out
  • Quaternion scalar multiplication and save the results to out quaternion

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: number

    Returns Out

Static normalize

  • normalize<Out>(out: Out, a: Out): Out

Static rotateAround

  • rotateAround<Out, VecLike>(out: Out, rot: Out, axis: VecLike, rad: number): Out
  • Sets the out quaternion to represent a radian rotation around a given rotation axis in world space

    Type parameters

    Parameters

    • out: Out
    • rot: Out
    • axis: VecLike

      axis of rotation, normalized by default

    • rad: number

      radius of rotation

    Returns Out

Static rotateAroundLocal

  • rotateAroundLocal<Out, VecLike>(out: Out, rot: Out, axis: VecLike, rad: number): Out
  • Sets the out quaternion to represent a radian rotation around a given rotation axis in local space

    Type parameters

    Parameters

    • out: Out
    • rot: Out
    • axis: VecLike

      axis of rotation

    • rad: number

      radius of rotation

    Returns Out

Static rotateX

  • rotateX<Out>(out: Out, a: Out, rad: number): Out
  • Sets the out quaternion to represent a radian rotation around x axis

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      radius of rotation

    Returns Out

Static rotateY

  • rotateY<Out>(out: Out, a: Out, rad: number): Out
  • Sets the out quaternion to represent a radian rotation around y axis

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      radius of rotation

    Returns Out

Static rotateZ

  • rotateZ<Out>(out: Out, a: Out, rad: number): Out
  • Sets the out quaternion to represent a radian rotation around z axis

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      radius of rotation

    Returns Out

Static rotationTo

  • rotationTo<Out, VecLike>(out: Out, a: VecLike, b: VecLike): Out
  • Sets the out quaternion with the shortest path orientation between two vectors, considering both vectors normalized

    Type parameters

    Parameters

    • out: Out
    • a: VecLike
    • b: VecLike

    Returns Out

Static scaleAndAdd

  • scaleAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): Out
  • Quaternion multiplication and addition: A + B * scale

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out
    • scale: number

    Returns Out

Static set

  • set<Out>(out: Out, x: number, y: number, z: number, w: number): Out
  • Sets the out quaternion with values of each component

    Type parameters

    Parameters

    • out: Out
    • x: number
    • y: number
    • z: number
    • w: number

    Returns Out

Static slerp

  • slerp<Out, QuatLike_1, QuatLike_2>(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out

Static sqlerp

  • sqlerp<Out>(out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out
  • Spherical quaternion interpolation with two control points

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out
    • c: Out
    • d: Out
    • t: number

    Returns Out

Static strictEquals

Static toArray

  • toArray<Out>(out: Out, q: IQuatLike, ofs?: number): Out
  • Converts quaternion to an array

    Type parameters

    • Out: IWritableArrayLike<number>

    Parameters

    • out: Out
    • q: IQuatLike
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static toAxisX

Static toAxisY

Static toAxisZ

Static toEuler

  • Converts the quaternion to angles, result angle x, y in the range of [-180, 180], z in the range of [-90, 90] interval, the rotation order is YZX

    Parameters

    • out: IVec3Like
    • q: IQuatLike
    • Optional outerZ: undefined | false | true

      change z value range to [-180, -90] U [90, 180]

    Returns IVec3Like

Generated using TypeDoc