Skip to content

Documentation / base / ObservableQuaternion

Class: ObservableQuaternion ​

Defined in: libs/base/src/math/vector.ts:2588

Observable 4 dimentional vector

Extends ​

Indexable ​

[index: number]: number

Constructors ​

Constructor ​

new ObservableQuaternion(x, y, z, w): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1810

Creates a new Quaternion initialized with values.

Parameters ​

x ​

number

The x component.

y ​

number

The y component.

z ​

number

The z component.

w ​

number

The w component.

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.constructor

Constructor ​

new ObservableQuaternion(elements): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1815

Creates a new Quaternion initialized with values in an array.

Parameters ​

elements ​

number[]

Array that contains the x, y, z, w values.

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.constructor

Constructor ​

new ObservableQuaternion(array): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1820

Creates a new Quaternion initialized with values in a Float32Array.

Parameters ​

array ​

Float32Array

Float32Array object that contains the x, y, z, w values.

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.constructor

Constructor ​

new ObservableQuaternion(buffer, offset): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1826

Creates a new Quaternion placed on a given ArrayBuffer object.

Parameters ​

buffer ​

ArrayBuffer

The array buffer object.

offset ​

number

The byte offset of the buffer where the vector placed at.

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.constructor

Constructor ​

new ObservableQuaternion(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1830

Creates a new identity Quaternion.

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.constructor

Accessors ​

magnitude ​

Get Signature ​

get magnitude(): number

Defined in: libs/base/src/math/vector.ts:1940

Get the length of the quaternion.

Returns ​

number

Inherited from ​

Quaternion.magnitude


magnitudeSq ​

Get Signature ​

get magnitudeSq(): number

Defined in: libs/base/src/math/vector.ts:1944

Get the squared length of the quaternion.

Returns ​

number

Inherited from ​

Quaternion.magnitudeSq


callback ​

Get Signature ​

get callback(): () => void

Defined in: libs/base/src/math/vector.ts:2592

The callback function which will be executed when the value changed

Returns ​

() => void

Set Signature ​

set callback(cb): void

Defined in: libs/base/src/math/vector.ts:2595

Parameters ​
cb ​

() => void

Returns ​

void


x ​

Get Signature ​

get x(): number

Defined in: libs/base/src/math/vector.ts:2606

Get the x component value.

Returns ​

number

Set Signature ​

set x(val): void

Defined in: libs/base/src/math/vector.ts:2609

Get the x component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Quaternion.x


y ​

Get Signature ​

get y(): number

Defined in: libs/base/src/math/vector.ts:2619

Get the y component value.

Returns ​

number

Set Signature ​

set y(val): void

Defined in: libs/base/src/math/vector.ts:2622

Get the y component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Quaternion.y


z ​

Get Signature ​

get z(): number

Defined in: libs/base/src/math/vector.ts:2632

Get the z component value.

Returns ​

number

Set Signature ​

set z(val): void

Defined in: libs/base/src/math/vector.ts:2635

Get the z component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Quaternion.z


w ​

Get Signature ​

get w(): number

Defined in: libs/base/src/math/vector.ts:2645

Get the w component value.

Returns ​

number

Set Signature ​

set w(val): void

Defined in: libs/base/src/math/vector.ts:2648

Get the w component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Quaternion.w

Methods ​

equalsTo() ​

equalsTo(other, epsl?): boolean

Defined in: libs/base/src/math/vector.ts:32

Check if all data is close enough to another

Parameters ​

other ​

Float32Array<ArrayBuffer>

The data to be compared with.

epsl? ​

number

Returns ​

boolean

true if close enough, otherwise false.

Inherited from ​

Quaternion.equalsTo


toString() ​

toString(): string

Defined in: libs/base/src/math/vector.ts:52

Convert this to string object.

Returns ​

string

Inherited from ​

Quaternion.toString


isNaN() ​

isNaN(): boolean

Defined in: libs/base/src/math/vector.ts:61

Check the data for the presence of NaN.

Returns ​

boolean

true if NaN is present, otherwise false.

Inherited from ​

Quaternion.isNaN


setRandom() ​

setRandom(minValue, maxValue): void

Defined in: libs/base/src/math/vector.ts:75

Generate random vector

Parameters ​

minValue ​

number

Minimum value of any component of the vector

maxValue ​

number

Maximum value of any component of the vector

Returns ​

void

Inherited from ​

Quaternion.setRandom


clone() ​

clone(): Quaternion

Defined in: libs/base/src/math/vector.ts:1872

Creates a new Quaternion initialized with values from this quaternion.

Returns ​

Quaternion

The new quaternion.

Inherited from ​

Quaternion.clone


scaleBy() ​

scaleBy(f): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1923

Scale this quaternion by a scalar number.

Parameters ​

f ​

number

amount to scale this quaternion by.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.scaleBy


setAndNormalize() ​

setAndNormalize(x, y, z, w): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1935

Set component values and then normalize the quaternion.

Parameters ​

x ​

number

The x component value.

y ​

number

The y component value.

z ​

number

The z component value.

w ​

number

The w component value.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.setAndNormalize


identity() ​

identity(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1948

Make this quaternion an identity quaternion

Returns ​

ObservableQuaternion

Inherited from ​

Quaternion.identity


inplaceNormalize() ​

inplaceNormalize(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1956

Normalize this quaternion inplace.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.inplaceNormalize


inplaceConjugate() ​

inplaceConjugate(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1964

Calculates the conjugate of this quaternion inplace.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.inplaceConjugate


inplaceInverse() ​

inplaceInverse(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1972

Calculates the inverse of this quaternion inplace.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.inplaceInverse


multiplyRight() ​

multiplyRight(other): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1981

Multiply this quaternion by another quaternion at the right side inplace.

Parameters ​

other ​

Quaternion

The quaternion that to be multiplied by.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.multiplyRight


multiplyLeft() ​

multiplyLeft(other): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:1990

Multiply this quaternion by another quaternion at the left side inplace.

Parameters ​

other ​

Quaternion

The quaternion that to be multiplied by.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.multiplyLeft


unitVectorToUnitVector() ​

unitVectorToUnitVector(from, to): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2000

Make a quaternion used to rotate a unit vector to another inplace.

Parameters ​

from ​

Vector3

The unit vector to be rotated.

to ​

Vector3

The destination unit vector.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.unitVectorToUnitVector


fromEulerAngle() ​

fromEulerAngle(x, y, z, order?): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2012

Calculates the quaternion from an euler angle in specific order inplace.

Parameters ​

x ​

number

Angle to rotate around X axis in radians.

y ​

number

Angle to rotate around Y axis in radians.

z ​

number

Angle to rotate around Z axis in radians.

order? ​

EulerAngleOrder = 'ZYX'

Intrinsic order for conversion.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.fromEulerAngle


fromAxisAngle() ​

fromAxisAngle(axis, angle): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2022

Calculates the quaternion from the given angle and rotation axis inplace.

Parameters ​

axis ​

Vector3

The rotation axis.

angle ​

number

The rotate angle.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.fromAxisAngle


toAxisAngle() ​

toAxisAngle(axis): number

Defined in: libs/base/src/math/vector.ts:2031

Calculates the rotation axis and angle for this quaternion

Parameters ​

axis ​

Vector3

A vector that receives the rotation axis.

Returns ​

number

  • The rotation angle

Inherited from ​

Quaternion.toAxisAngle


toEulerAngles() ​

toEulerAngles(angles?): Vector3

Defined in: libs/base/src/math/vector.ts:2046

Convert this rotation to euler angles in ZYX order

Parameters ​

angles? ​

Vector3

A vector that receives the euler angles. If not given, a new vector will be created.

Returns ​

Vector3

The vector that holds the euler angles.

Inherited from ​

Quaternion.toEulerAngles


fromRotationMatrix() ​

fromRotationMatrix(matrix): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2063

Calculates the quaternion from a rotation matrix inplace.

Parameters ​

matrix ​

Matrix3x3 | Matrix4x4

The rotation matrix.

Returns ​

ObservableQuaternion

self

Inherited from ​

Quaternion.fromRotationMatrix


decomposeSwingTwist() ​

decomposeSwingTwist(axis, outSwing?, outTwist?): void

Defined in: libs/base/src/math/vector.ts:2085

Decompose the quaternion into swing and twist components around a given axis.

Parameters ​

axis ​

Vector3

The twist axis (must be normalized)

outSwing? ​

Quaternion

Output swing rotation

outTwist? ​

Quaternion

Output twist rotation

Returns ​

void

Remarks ​

Given a rotation Q and an axis A, decompose Q into:

  • Twist: rotation around A
  • Swing: rotation perpendicular to A Such that Q = Twist * Swing

Algorithm:

  1. Project Q's imaginary part onto axis to get twist component
  2. Normalize to get pure twist rotation
  3. Calculate swing = twist^-1 * Q

Inherited from ​

Quaternion.decomposeSwingTwist


getTwistAngle() ​

getTwistAngle(axis): number

Defined in: libs/base/src/math/vector.ts:2133

Get the twist angle (in radians) around an axis.

Parameters ​

axis ​

Vector3

The twist axis (must be normalized)

Returns ​

number

Twist angle in radians, range [-PI, PI]

Inherited from ​

Quaternion.getTwistAngle


toMatrix3x3() ​

toMatrix3x3(matrix?): Matrix3x3

Defined in: libs/base/src/math/vector.ts:2158

Convert this quaternion to a 3x3 rotation matrix.

Parameters ​

matrix? ​

Matrix3x3

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix3x3

The output matrix.

Inherited from ​

Quaternion.toMatrix3x3


toMatrix4x4() ​

toMatrix4x4(matrix?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:2172

Convert this quaternion to a 4x4 rotation matrix.

Parameters ​

matrix? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix.

Remarks ​

Only left top 3x3 part of the matrix will be changed.

Inherited from ​

Quaternion.toMatrix4x4


getDirectionX() ​

getDirectionX(result?): Vector3

Defined in: libs/base/src/math/vector.ts:2189

Get the direction of axis x

Parameters ​

result? ​

Vector3

The output vector, if not specified, a new vector will be created.

Returns ​

Vector3

The direction of axis x

Inherited from ​

Quaternion.getDirectionX


getDirectionY() ​

getDirectionY(result?): Vector3

Defined in: libs/base/src/math/vector.ts:2202

Get the direction of axis y

Parameters ​

result? ​

Vector3

The output vector, if not specified, a new vector will be created.

Returns ​

Vector3

The direction of axis y

Inherited from ​

Quaternion.getDirectionY


getDirectionZ() ​

getDirectionZ(result?): Vector3

Defined in: libs/base/src/math/vector.ts:2215

Get the direction of axis z

Parameters ​

result? ​

Vector3

The output vector, if not specified, a new vector will be created.

Returns ​

Vector3

The direction of axis z

Inherited from ​

Quaternion.getDirectionZ


getAxisAngle() ​

getAxisAngle(result?): Vector4

Defined in: libs/base/src/math/vector.ts:2228

Get the rotate angle and the rotation axis for this quaternion.

Parameters ​

result? ​

Vector4

The output vector, if not specified, a new vector will be created.

Returns ​

Vector4

An vector4 that the x, y, z component presents the axis and the w component presents the angle.

Inherited from ​

Quaternion.getAxisAngle


transform() ​

transform(v, result?): Vector3

Defined in: libs/base/src/math/vector.ts:2245

Rotate a vector

Parameters ​

v ​

Vector3

The vector to be rotated.

result? ​

Vector3

The output vector, if not specified, a new vector will be created.

Returns ​

Vector3

The rotation result.

Inherited from ​

Quaternion.transform


scale() ​

static scale(q, t, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2272

Scale a Quaternion by a scalar number.

Parameters ​

q ​

Quaternion

t ​

number

result? ​

Quaternion

The output quaternion (can be the same quaternion as a). if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.scale


dot() ​

static dot(a, b): number

Defined in: libs/base/src/math/vector.ts:2282

Calculates the dot product of two Quaternion's.

Parameters ​

a ​

Quaternion

The first operand.

b ​

Quaternion

The second operand.

Returns ​

number

dot product of a and b

Inherited from ​

Quaternion.dot


identity() ​

static identity(q?): Quaternion

Defined in: libs/base/src/math/vector.ts:2290

Create an identity quaternion

Parameters ​

q? ​

Quaternion

The output quaternion, if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.identity


normalize() ​

static normalize(q, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2299

Normalize a quaternion

Parameters ​

q ​

Quaternion

The input quaternion

result? ​

Quaternion

The output quaternion (can be the same as q), if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.normalize


conjugate() ​

static conjugate(q, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2309

Gets the conjugate of a quaternion

Parameters ​

q ​

Quaternion

The input quaternion

result? ​

Quaternion

The output quaternion (can be the same as q), if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.conjugate


inverse() ​

static inverse(q, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2318

Gets the inverse of a quaternion

Parameters ​

q ​

Quaternion

The input quaternion

result? ​

Quaternion

The output quaternion (can be the same as q), if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.inverse


multiply() ​

static multiply(a, b, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2336

Multiply two Quaternion's.

Parameters ​

a ​

Quaternion

The first operand.

b ​

Quaternion

The second operand.

result? ​

Quaternion

The output quaternion (can be the same as a or b). if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.multiply


slerp() ​

static slerp(a, b, t, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2352

Performs a spherical linear interpolation between two quat.

Parameters ​

a ​

Quaternion

The first operand.

b ​

Quaternion

The second operand.

t ​

number

The interpolation amount, in the range [0-1].

result? ​

Quaternion

The output quaternion (can be the same as a or b), if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.slerp


angleBetween() ​

static angleBetween(a, b): number

Defined in: libs/base/src/math/vector.ts:2401

Gets the angular distance between two unit quaternions.

Parameters ​

a ​

Quaternion

The origin quaternion

b ​

Quaternion

The destination quaternion

Returns ​

number

  • The angle in radians

Inherited from ​

Quaternion.angleBetween


unitVectorToUnitVector() ​

static unitVectorToUnitVector(from, to, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2413

Creates a quaternion used to rotate a unit vector to another.

Parameters ​

from ​

Vector3

The unit vector to be rotated.

to ​

Vector3

The destination unit vector.

result? ​

Quaternion

The output quaternion, if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.unitVectorToUnitVector


fromEulerAngle() ​

static fromEulerAngle(a, b, c, order?, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2442

Creates a quaternion from an euler angle in specific order.

Parameters ​

a ​

number

b ​

number

c ​

number

order? ​

EulerAngleOrder = 'ZYX'

Intrinsic order for conversion.

result? ​

Quaternion

The output quaternion, if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.fromEulerAngle


fromAxisAngle() ​

static fromAxisAngle(axis, angle, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2508

Creates a quaternion from the given angle and rotation axis.

Parameters ​

axis ​

Vector3

The rotation axis.

angle ​

number

The rotate angle.

result? ​

Quaternion

The output quaternion, if not specified, a new quaternion will be created.

Returns ​

Quaternion

The output quaternion

Inherited from ​

Quaternion.fromAxisAngle


fromRotationMatrix() ​

static fromRotationMatrix(matrix, result?): Quaternion

Defined in: libs/base/src/math/vector.ts:2521

Creates a quaternion from a rotation matrix.

Parameters ​

matrix ​

Matrix3x3 | Matrix4x4

The rotation matrix.

result? ​

Quaternion

The output quaternion, if not specified, a new quaternion will be created.

Returns ​

Quaternion

self

Inherited from ​

Quaternion.fromRotationMatrix


setCallback() ​

setCallback(cb): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2599

Set callback

Parameters ​

cb ​

() => void

Returns ​

ObservableQuaternion


setXYZW() ​

setXYZW(x, y, z, w): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2658

Set component values.

Parameters ​

x ​

number

The x component value.

y ​

number

The y component value.

z ​

number

The z component value.

w ​

number

The w component value.

Returns ​

ObservableQuaternion

self

Overrides ​

Quaternion.setXYZW


copyWithin() ​

copyWithin(target, start, end?): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2672

Inherited from Float32Array.copyWithin

Parameters ​

target ​

number

start ​

number

end? ​

number

Returns ​

ObservableQuaternion

Overrides ​

Quaternion.copyWithin


fill() ​

fill(value, start?, end?): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2680

Inherited from Float32Array.fill

Parameters ​

value ​

number

start? ​

number

end? ​

number

Returns ​

ObservableQuaternion

Overrides ​

Quaternion.fill


reverse() ​

reverse(): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2688

Inherited from Float32Array.reverse

Returns ​

ObservableQuaternion

Overrides ​

Quaternion.reverse


set() ​

set(array, offset?): void

Defined in: libs/base/src/math/vector.ts:2696

Inherited from Float32Array.set

Parameters ​

array ​

ArrayLike<number>

offset? ​

number

Returns ​

void

Overrides ​

Quaternion.set


sort() ​

sort(compareFn?): ObservableQuaternion

Defined in: libs/base/src/math/vector.ts:2703

Inherited from Float32Array.sort

Parameters ​

compareFn? ​

(a, b) => number

Returns ​

ObservableQuaternion

Overrides ​

Quaternion.sort

Released under the MIT License.