Skip to content

Documentation / base / ObservableQuaternion

Class: ObservableQuaternion

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

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:1809

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:1814

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:1819

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:1825

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:1829

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:1939

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:1943

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:2591

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:2594

Parameters
cb

() => void

Returns

void


x

Get Signature

get x(): number

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

Get the x component value.

Returns

number

Set Signature

set x(val): void

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

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:2618

Get the y component value.

Returns

number

Set Signature

set y(val): void

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

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:2631

Get the z component value.

Returns

number

Set Signature

set z(val): void

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

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:2644

Get the w component value.

Returns

number

Set Signature

set w(val): void

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

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:31

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:51

Convert this to string object.

Returns

string

Inherited from

Quaternion.toString


isNaN()

isNaN(): boolean

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

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:74

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:1871

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:1922

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:1934

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:1947

Make this quaternion an identity quaternion

Returns

ObservableQuaternion

Inherited from

Quaternion.identity


inplaceNormalize()

inplaceNormalize(): ObservableQuaternion

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

Normalize this quaternion inplace.

Returns

ObservableQuaternion

self

Inherited from

Quaternion.inplaceNormalize


inplaceConjugate()

inplaceConjugate(): ObservableQuaternion

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

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:1971

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:1980

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:1989

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:1999

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:2011

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:2021

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:2030

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:2045

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:2062

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:2084

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:2132

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:2157

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:2171

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:2188

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:2201

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:2214

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:2227

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:2244

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:2271

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:2281

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:2289

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:2298

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:2308

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:2317

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:2335

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:2351

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:2400

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:2412

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:2441

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:2507

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:2520

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:2598

Set callback

Parameters

cb

() => void

Returns

ObservableQuaternion


setXYZW()

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

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

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:2671

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:2679

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:2687

Inherited from Float32Array.reverse

Returns

ObservableQuaternion

Overrides

Quaternion.reverse


set()

set(array, offset?): void

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

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:2702

Inherited from Float32Array.sort

Parameters

compareFn?

(a, b) => number

Returns

ObservableQuaternion

Overrides

Quaternion.sort

Released under the MIT License.