Options
All
• Public
• Public/Protected
• All

Class Quat

quaternion

Constructors

constructor

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

Properties

w: number

w component.

x: number

x component.

y: number

y component.

z: number

z component.

Static IDENTITY

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

Methods

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

• Convert quaternion to Euler angles

Parameters

• out: Vec3

the output vector

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].

set

• set(other: Quat): Quat
• set(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat
• Set values with another quaternion

Parameters

• other: Quat

Specified quaternion

Returns Quat

this

• Set the value of each component of the current quaternion

this

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].

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

Static clone

• clone<Out>(a: Out): Quat
• Obtain a copy of the given quaternion

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

Static copy

• copy<Out, QuatLike>(out: Out, a: QuatLike): Out
• Copy the given quaternion to the out quaternion

Static dot

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

Static equals

• Check whether two quaternions are approximately equal

Static fromAngleZ

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

Parameters

• out: Out

Output quaternion

• z: number

Angle to rotate around Z axis in degrees.

Static fromArray

• Array to a quaternion

Parameters

• Default value ofs: number = 0

Array Start Offset

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

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.

Static fromEuler

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

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

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

Parameters

• 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).

Static getAxisAngle

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

Parameters

• outAxis: VecLike

output axis

• q: Out

input quaternion

Static identity

• identity<Out>(out: Out): Out
• Sets the out quaternion to an identity quaternion

Static invert

• invert<Out, QuatLike>(out: Out, a: QuatLike): Out
• Sets the inverse of the given quaternion to out quaternion

Static len

• len<Out>(a: Out): number
• Calculates the length of the quaternion

Static lengthSqr

• lengthSqr<Out>(a: Out): number
• Calculates the squared length of the quaternion

Static lerp

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

Static multiply

• multiply<Out, QuatLike_1, QuatLike_2>(out: Out, a: QuatLike_1, b: QuatLike_2): Out
• Quaternion multiplication and save the results to out quaternion

Static multiplyScalar

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

Static normalize

• normalize<Out>(out: Out, a: Out): Out
• Normalize the given quaternion

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

Parameters

• axis: VecLike

axis of rotation, normalized by default

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

Parameters

• axis: VecLike

axis of rotation

Static rotateX

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

Static rotateY

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

Static rotateZ

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

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

Returns Out

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

Static set

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

Static slerp

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

Static sqlerp

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

Static strictEquals

• Check whether two quaternions are equal

Static toArray

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

Parameters

• Default value ofs: number = 0

Array Start Offset

Static toAxisX

• This returns the X-axis vector of the quaternion

Static toAxisY

• This returns the Y-axis vector of the quaternion

Static toAxisZ

• This returns the Z-axis vector of the quaternion

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

• Optional outerZ: undefined | false | true

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

Returns IVec3Like

Generated using TypeDoc