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
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
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
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
Constructor
new ObservableQuaternion():
ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:1829
Creates a new identity Quaternion.
Returns
ObservableQuaternion
Inherited from
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
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
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
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
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
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
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
toString()
toString():
string
Defined in: libs/base/src/math/vector.ts:51
Convert this to string object.
Returns
string
Inherited from
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
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
clone()
clone():
Quaternion
Defined in: libs/base/src/math/vector.ts:1871
Creates a new Quaternion initialized with values from this quaternion.
Returns
The new quaternion.
Inherited from
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
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
identity()
identity():
ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:1947
Make this quaternion an identity quaternion
Returns
ObservableQuaternion
Inherited from
inplaceNormalize()
inplaceNormalize():
ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:1955
Normalize this quaternion inplace.
Returns
ObservableQuaternion
self
Inherited from
inplaceConjugate()
inplaceConjugate():
ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:1963
Calculates the conjugate of this quaternion inplace.
Returns
ObservableQuaternion
self
Inherited from
inplaceInverse()
inplaceInverse():
ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:1971
Calculates the inverse of this quaternion inplace.
Returns
ObservableQuaternion
self
Inherited from
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
The quaternion that to be multiplied by.
Returns
ObservableQuaternion
self
Inherited from
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
The quaternion that to be multiplied by.
Returns
ObservableQuaternion
self
Inherited from
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
The unit vector to be rotated.
to
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
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
The rotation axis.
angle
number
The rotate angle.
Returns
ObservableQuaternion
self
Inherited from
toAxisAngle()
toAxisAngle(
axis):number
Defined in: libs/base/src/math/vector.ts:2030
Calculates the rotation axis and angle for this quaternion
Parameters
axis
A vector that receives the rotation axis.
Returns
number
- The rotation angle
Inherited from
toEulerAngles()
toEulerAngles(
angles?):Vector3
Defined in: libs/base/src/math/vector.ts:2045
Convert this rotation to euler angles in ZYX order
Parameters
angles?
A vector that receives the euler angles. If not given, a new vector will be created.
Returns
The vector that holds the euler angles.
Inherited from
fromRotationMatrix()
fromRotationMatrix(
matrix):ObservableQuaternion
Defined in: libs/base/src/math/vector.ts:2062
Calculates the quaternion from a rotation matrix inplace.
Parameters
matrix
The rotation matrix.
Returns
ObservableQuaternion
self
Inherited from
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
The twist axis (must be normalized)
outSwing?
Output swing rotation
outTwist?
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:
- Project Q's imaginary part onto axis to get twist component
- Normalize to get pure twist rotation
- 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
The twist axis (must be normalized)
Returns
number
Twist angle in radians, range [-PI, PI]
Inherited from
toMatrix3x3()
toMatrix3x3(
matrix?):Matrix3x3
Defined in: libs/base/src/math/vector.ts:2157
Convert this quaternion to a 3x3 rotation matrix.
Parameters
matrix?
The output matrix, if not specified, a new matrix will be created.
Returns
The output matrix.
Inherited from
toMatrix4x4()
toMatrix4x4(
matrix?):Matrix4x4
Defined in: libs/base/src/math/vector.ts:2171
Convert this quaternion to a 4x4 rotation matrix.
Parameters
matrix?
The output matrix, if not specified, a new matrix will be created.
Returns
The output matrix.
Remarks
Only left top 3x3 part of the matrix will be changed.
Inherited from
getDirectionX()
getDirectionX(
result?):Vector3
Defined in: libs/base/src/math/vector.ts:2188
Get the direction of axis x
Parameters
result?
The output vector, if not specified, a new vector will be created.
Returns
The direction of axis x
Inherited from
getDirectionY()
getDirectionY(
result?):Vector3
Defined in: libs/base/src/math/vector.ts:2201
Get the direction of axis y
Parameters
result?
The output vector, if not specified, a new vector will be created.
Returns
The direction of axis y
Inherited from
getDirectionZ()
getDirectionZ(
result?):Vector3
Defined in: libs/base/src/math/vector.ts:2214
Get the direction of axis z
Parameters
result?
The output vector, if not specified, a new vector will be created.
Returns
The direction of axis z
Inherited from
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?
The output vector, if not specified, a new vector will be created.
Returns
An vector4 that the x, y, z component presents the axis and the w component presents the angle.
Inherited from
transform()
transform(
v,result?):Vector3
Defined in: libs/base/src/math/vector.ts:2244
Rotate a vector
Parameters
v
The vector to be rotated.
result?
The output vector, if not specified, a new vector will be created.
Returns
The rotation result.
Inherited from
scale()
staticscale(q,t,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2271
Scale a Quaternion by a scalar number.
Parameters
q
t
number
result?
The output quaternion (can be the same quaternion as a). if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
dot()
staticdot(a,b):number
Defined in: libs/base/src/math/vector.ts:2281
Calculates the dot product of two Quaternion's.
Parameters
a
The first operand.
b
The second operand.
Returns
number
dot product of a and b
Inherited from
identity()
staticidentity(q?):Quaternion
Defined in: libs/base/src/math/vector.ts:2289
Create an identity quaternion
Parameters
q?
The output quaternion, if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
normalize()
staticnormalize(q,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2298
Normalize a quaternion
Parameters
q
The input quaternion
result?
The output quaternion (can be the same as q), if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
conjugate()
staticconjugate(q,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2308
Gets the conjugate of a quaternion
Parameters
q
The input quaternion
result?
The output quaternion (can be the same as q), if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
inverse()
staticinverse(q,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2317
Gets the inverse of a quaternion
Parameters
q
The input quaternion
result?
The output quaternion (can be the same as q), if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
multiply()
staticmultiply(a,b,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2335
Multiply two Quaternion's.
Parameters
a
The first operand.
b
The second operand.
result?
The output quaternion (can be the same as a or b). if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
slerp()
staticslerp(a,b,t,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2351
Performs a spherical linear interpolation between two quat.
Parameters
a
The first operand.
b
The second operand.
t
number
The interpolation amount, in the range [0-1].
result?
The output quaternion (can be the same as a or b), if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
angleBetween()
staticangleBetween(a,b):number
Defined in: libs/base/src/math/vector.ts:2400
Gets the angular distance between two unit quaternions.
Parameters
a
The origin quaternion
b
The destination quaternion
Returns
number
- The angle in radians
Inherited from
unitVectorToUnitVector()
staticunitVectorToUnitVector(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
The unit vector to be rotated.
to
The destination unit vector.
result?
The output quaternion, if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
Quaternion.unitVectorToUnitVector
fromEulerAngle()
staticfromEulerAngle(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?
The output quaternion, if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
fromAxisAngle()
staticfromAxisAngle(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
The rotation axis.
angle
number
The rotate angle.
result?
The output quaternion, if not specified, a new quaternion will be created.
Returns
The output quaternion
Inherited from
fromRotationMatrix()
staticfromRotationMatrix(matrix,result?):Quaternion
Defined in: libs/base/src/math/vector.ts:2520
Creates a quaternion from a rotation matrix.
Parameters
matrix
The rotation matrix.
result?
The output quaternion, if not specified, a new quaternion will be created.
Returns
self
Inherited from
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
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