Skip to content

Class: Quaternion

Quaternions are used to represent rotations.

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Quaternion(x?, y?, z?, w?): Quaternion

Create a new quaternion object

Parameters

NameTypeDefault valueDescription
xnumber0The X component of a quaternion.
ynumber0The Y component of a quaternion.
znumber0The Z component of a quaternion.
wnumber1The W component of a quaternion.

Returns

Quaternion

Defined in

src/math/Quaternion.ts:40

Properties

HELP_0

Static HELP_0: Quaternion

Defined in

src/math/Quaternion.ts:11


HELP_1

Static HELP_1: Quaternion

Defined in

src/math/Quaternion.ts:12


HELP_2

Static HELP_2: Quaternion

Defined in

src/math/Quaternion.ts:13


_zero

Static _zero: Quaternion

Defined in

src/math/Quaternion.ts:14


CALCULATION_QUATERNION

Static CALCULATION_QUATERNION: Quaternion

Defined in

src/math/Quaternion.ts:15

Accessors

magnitude

get magnitude(): number

Returns

number

Defined in

src/math/Quaternion.ts:102

Methods

identity

identity(): Quaternion

Identity quaternion

Returns

Quaternion

Defined in

src/math/Quaternion.ts:51


quaternionToMatrix

quaternionToMatrix(q, m): void

Converts quaternions to matrices

Parameters

NameTypeDescription
qQuaternionQuaternion
manyMatrix

Returns

void

Defined in

src/math/Quaternion.ts:60


set

set(x?, y?, z?, w?): Quaternion

Set the x, y, z, and w components of the existing quaternions.

Parameters

NameTypeDefault valueDescription
xnumber0The X component of a quaternion.
ynumber0The Y component of a quaternion.
znumber0The Z component of a quaternion.
wnumber1The W component of a quaternion.

Returns

Quaternion

Defined in

src/math/Quaternion.ts:113


divide

divide(v): Quaternion

Parameters

NameType
vany

Returns

Quaternion

Defined in

src/math/Quaternion.ts:121


multiply

multiply(qa, qb): void

Multiply two quaternions

Parameters

NameTypeDescription
qaQuaternionQuaternion 1
qbQuaternionQuaternion 2

Returns

void

Defined in

src/math/Quaternion.ts:149


multiplyVector

multiplyVector(vector, target?): Quaternion

Parameters

NameTypeDefault value
vectorVector3undefined
targetQuaternionnull

Returns

Quaternion

Defined in

src/math/Quaternion.ts:165


fromAxisAngle

fromAxisAngle(axis, angle): void

Set the quaternion with a given rotation of the axis and Angle.

Parameters

NameTypeDescription
axisVector3axis
anglenumberangle

Returns

void

Defined in

src/math/Quaternion.ts:184


toAxisAngle

toAxisAngle(axis): number

Turn quaternions into angles

Parameters

NameTypeDescription
axisVector3axis

Returns

number

Defined in

src/math/Quaternion.ts:202


slerp

slerp(qa, qb, t): void

Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.

Parameters

NameTypeDescription
qaQuaternionThe first quaternion to interpolate.
qbQuaternionThe second quaternion to interpolate.
tnumberThe interpolation weight, a value between 0 and 1.

Returns

void

Defined in

src/math/Quaternion.ts:227


lerp

lerp(qa, qb, t): void

Linearly interpolates between two quaternions.

Parameters

NameTypeDescription
qaQuaternionThe first quaternion to interpolate.
qbQuaternionThe second quaternion to interpolate.
tnumberThe interpolation weight, a value between 0 and 1.

Returns

void

Defined in

src/math/Quaternion.ts:277


fromEulerAngles

fromEulerAngles(ax, ay, az): Quaternion

Fills the quaternion object with values representing the given euler rotation.

Parameters

NameTypeDescription
axnumberThe angle in radians of the rotation around the ax axis.
aynumberThe angle in radians of the rotation around the ay axis.
aznumberThe angle in radians of the rotation around the az axis.

Returns

Quaternion

Defined in

src/math/Quaternion.ts:314


setFromRotationMatrix

setFromRotationMatrix(m): Quaternion

Sets the current quaternion from the rotation matrix

Parameters

NameType
mObject
m.rawDataFloat32Array

Returns

Quaternion

Defined in

src/math/Quaternion.ts:342


getEulerAngles

getEulerAngles(eulers?): Vector3

Get the Euler Angle

Parameters

NameType
eulers?Vector3

Returns

Vector3

Defined in

src/math/Quaternion.ts:393


normalize

normalize(val?): void

The normalize of the quaternion. Convert this quaternion to a normalize coefficient.

Parameters

NameTypeDefault valueDescription
valnumber1normalize coefficient, which is 1 by default

Returns

void

Defined in

src/math/Quaternion.ts:432


toString

toString(): string

Returns the value of a quaternion as a string

Returns

string

Defined in

src/math/Quaternion.ts:445


fromMatrix

fromMatrix(matrix): void

Extracts a quaternion rotation matrix out of a given Matrix3D object.

Parameters

NameTypeDescription
matrixanyThe Matrix3D out of which the rotation will be extracted.

Returns

void

Defined in

src/math/Quaternion.ts:453


inverse

inverse(target?): Quaternion

Returns a quaternion that inverts the current quaternion

Parameters

NameTypeDefault valueDescription
targetQuaternionnullThe default parameter is null. If the current parameter is null, a new quaternion object is returned

Returns

Quaternion

Quaternion Result

Defined in

src/math/Quaternion.ts:466


clone

clone(): Quaternion

Clones the quaternion.

Returns

Quaternion

An exact duplicate of the current Quaternion.

Defined in

src/math/Quaternion.ts:486


transformVector

transformVector(vector, target?): Vector3

Rotates a point.

Parameters

NameTypeDefault valueDescription
vectorVector3undefinedThe Vector3D object to be rotated.
targetVector3nullAn optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created.

Returns

Vector3

A Vector3D object containing the rotated point.

Defined in

src/math/Quaternion.ts:496


copyFrom

copyFrom(q): this

Copies the data from a quaternion into this instance.

Parameters

NameTypeDescription
qVector3 | QuaternionThe quaternion to copy from.

Returns

this

Defined in

src/math/Quaternion.ts:523


mul

mul(lhs, rhs, target?): Quaternion

from untiy API op

Parameters

NameType
lhsQuaternion
rhsQuaternion
target?Quaternion

Returns

Quaternion

Defined in

src/math/Quaternion.ts:536


serialize

serialize(value): Quaternion

Parameters

NameType
valueQuaternion

Returns

Quaternion

Defined in

src/math/Quaternion.ts:554