Class Quaternion
Implements
- Tensor<Tuple<number, 4>, Quaternion>
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
Creates a new Quaternion from the given floats
Parameters
- x: number = 0.0
defines the first component (0 by default)
- y: number = 0.0
defines the second component (0 by default)
- z: number = 0.0
defines the third component (0 by default)
- w: number = 1.0
defines the fourth component (1.0 by default)
Returns Quaternion
- x: number = 0.0
Properties
Readonlydimension
Readonlyrank
Static_ V8 Performance Hack
If the first quaternion is flagged with integers (as everything is 0,0,0,0), V8 stores all of the properties as integers internally because it doesn't know any better yet. If subsequent quaternion are created with non-integer values, V8 determines that it would be best to represent these properties as doubles instead of integers, and henceforth it will use floating-point representation for all quaternion instances that it creates. But the original quaternion instances are unchanged and has a "deprecated map". If we keep using the quaternion instances from step 1, it will now be a poison pill which will mess up optimizations in any code it touches.
Accessors
w
-
get w(): number
Gets or sets the w coordinate
Returns number
-
set w(value: number): void
Parameters
- value: number
Returns void
x
-
get x(): number
Gets or sets the x coordinate
Returns number
-
set x(value: number): void
Parameters
- value: number
Returns void
y
-
get y(): number
Gets or sets the y coordinate
Returns number
-
set y(value: number): void
Parameters
- value: number
Returns void
z
-
get z(): number
Gets or sets the z coordinate
Returns number
-
set z(value: number): void
Parameters
- value: number
Returns void
Methods
add
-
Adds two quaternions Example Playground https://playground.babylonjs.com/#L49EJ7#10
Parameters
- other: DeepImmutable<Quaternion>
defines the second operand
Returns Quaternion
a new quaternion as the addition result of the given one and the current quaternion
- other: DeepImmutable<Quaternion>
add In Place
-
Add a quaternion to the current one Example Playground https://playground.babylonjs.com/#L49EJ7#11
Parameters
- other: DeepImmutable<Quaternion>
defines the quaternion to add
Returns this
the current quaternion
- other: DeepImmutable<Quaternion>
add In Place From Floats
-
Adds in place the given floats to the current quaternion
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns this
the current updated quaternion
- x: number
add To Ref
-
Sets the "result" coordinates with the addition of the current instance and the given one coordinates
Type Parameters
- T extends Quaternion
Parameters
- other: DeepImmutable<this>
defines the other instance
- result: T
defines the target instance
Returns T
result input
as Array
-
Copy the quaternion to an array Example Playground https://playground.babylonjs.com/#L49EJ7#13
Returns [number, number, number, number]
a new array populated with 4 elements from the quaternion coordinates
clone
-
Clone the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#12
Returns Quaternion
a new quaternion copied from the current one
conjugate
-
Conjugates (1-q) the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#83
Returns Quaternion
a new quaternion
conjugate In Place
-
Conjugates in place the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#82
Returns this
the current updated quaternion
conjugate To Ref
-
Conjugates the current quaternion and stores the result in the given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#81
Type Parameters
- T extends Quaternion
Parameters
- ref: T
defines the target quaternion
Returns T
result input
copy From
-
Copy a quaternion to the current one Example Playground https://playground.babylonjs.com/#L49EJ7#86
Parameters
- other: DeepImmutable<Quaternion>
defines the other quaternion
Returns this
the updated current quaternion
- other: DeepImmutable<Quaternion>
copy From Floats
-
Updates the current quaternion with the given float coordinates Example Playground https://playground.babylonjs.com/#L49EJ7#87
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns this
the updated current quaternion
- x: number
dot
-
Returns the dot product (float) between the current quaternions and "other"
Parameters
- other: DeepImmutable<this>
defines the right operand
Returns number
the dot product
- other: DeepImmutable<this>
equals
-
Check if two quaternions are equals Example Playground https://playground.babylonjs.com/#L49EJ7#38
Parameters
- otherQuaternion: DeepImmutable<Quaternion>
defines the second operand
Returns boolean
true if the current quaternion and the given one coordinates are strictly equals
- otherQuaternion: DeepImmutable<Quaternion>
equals To Floats
-
Determines if the current quaternion equals the given floats
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns boolean
true if the quaternion coordinates match the given floats
- x: number
equals With Epsilon
-
Gets a boolean if two quaternions are equals (using an epsilon value) Example Playground https://playground.babylonjs.com/#L49EJ7#37
Parameters
- otherQuaternion: DeepImmutable<Quaternion>
defines the other quaternion
- epsilon: number = Epsilon
defines the minimal distance to consider equality
Returns boolean
true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
- otherQuaternion: DeepImmutable<Quaternion>
from Array
-
Update the current instance from an array
Parameters
- array: FloatArray
defines the destination array
- index: number = 0
defines the offset in the destination array
Returns this
the current instance
- array: FloatArray
from Rotation Matrix
-
Updates the current quaternion from the given rotation matrix values Example Playground https://playground.babylonjs.com/#L49EJ7#41
Parameters
- matrix: DeepImmutable<Matrix>
defines the source matrix
Returns this
the current updated quaternion
- matrix: DeepImmutable<Matrix>
get Class Name
-
Gets the class name of the quaternion
Returns string
the string "Quaternion"
get Hash Code
-
Gets a hash code for this quaternion
Returns number
the quaternion hash code
invert
-
Returns the inverse of the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#84
Returns Quaternion
a new quaternion
invert In Place
-
Invert in place the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#85
Returns this
this quaternion
is Approx
-
Gets a boolean if two quaternions are equals (using an epsilon value), taking care of double cover : https://www.reedbeta.com/blog/why-quaternions-double-cover/
Parameters
- otherQuaternion: DeepImmutable<Quaternion>
defines the other quaternion
- epsilon: number = Epsilon
defines the minimal distance to consider equality
Returns boolean
true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
- otherQuaternion: DeepImmutable<Quaternion>
length
-
Gets length of current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#28
Returns number
the quaternion length (float)
length Squared
-
Gets squared length of current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#29
Returns number
the quaternion length (float)
multiply
-
Multiplies two quaternions Example Playground https://playground.babylonjs.com/#L49EJ7#43
Parameters
- q1: DeepImmutable<Quaternion>
defines the second operand
Returns Quaternion
a new quaternion set as the multiplication result of the current one with the given one "q1"
- q1: DeepImmutable<Quaternion>
multiply By Floats
-
Multiplies the current quaternion coordinates by the given floats
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns this
the current updated quaternion
- x: number
multiply In Place
-
Updates the current quaternion with the multiplication of itself with the given one "q1" Example Playground https://playground.babylonjs.com/#L49EJ7#46
Parameters
- other: DeepImmutable<Quaternion>
defines the second operand
Returns this
the currentupdated quaternion
- other: DeepImmutable<Quaternion>
multiply To Ref
-
Sets the given "result" as the multiplication result of the current one with the given one "q1" Example Playground https://playground.babylonjs.com/#L49EJ7#45
Type Parameters
- T extends Quaternion
Parameters
- q1: DeepImmutable<Quaternion>
defines the second operand
- result: T
defines the target quaternion
Returns T
the current quaternion
negate
negate In Place
-
Negate this instance in place
Returns this
this
negate To Ref
-
Negate the current instance and stores the result in the given instance "result" coordinates
Type Parameters
- T extends Quaternion
Parameters
- result: T
defines the instance object where to store the result
Returns T
the result
normalize
-
Normalize in place the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#54
Returns this
the current updated quaternion
normalize From Length
-
Normalize the current quaternion with the given input length. Please note that this is an in place operation.
Parameters
- len: number
the length of the quaternion
Returns this
the current updated Quaternion
- len: number
normalize To New
-
Normalize a copy of the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#55
Returns Quaternion
the normalized quaternion
normalize To Ref
-
Normalize the current Quaternion to the reference
Type Parameters
- T extends Quaternion
Parameters
- reference: T
define the Quaternion to update
Returns T
the updated Quaternion
scale
-
Multiplies the current quaternion by a scale factor Example Playground https://playground.babylonjs.com/#L49EJ7#88
Parameters
- value: number
defines the scale factor
Returns Quaternion
a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
- value: number
scale And Add To Ref
-
Scale the current quaternion values by a factor and add the result to a given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#91
Type Parameters
- T extends Quaternion
Parameters
- scale: number
defines the scale factor
- result: T
defines the Quaternion object where to store the result
Returns T
result input
scale In Place
-
Multiplies in place the current quaternion by a scale factor Example Playground https://playground.babylonjs.com/#L49EJ7#90
Parameters
- value: number
defines the scale factor
Returns this
the current modified quaternion
- value: number
scale To Ref
-
Scale the current quaternion values by a factor and stores the result to a given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#89
Type Parameters
- T extends Quaternion
Parameters
- scale: number
defines the scale factor
- result: T
defines the Quaternion object where to store the result
Returns T
result input
set
-
Updates the current quaternion from the given float coordinates Example Playground https://playground.babylonjs.com/#L49EJ7#56
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns this
the updated current quaternion
- x: number
set All
-
Sets all the quaternion coordinates to the given value
Parameters
- value: number
the value to set
Returns this
the current updated quaternion
- value: number
subtract
-
Subtract two quaternions Example Playground https://playground.babylonjs.com/#L49EJ7#57
Parameters
- other: DeepImmutable<this>
defines the second operand
Returns Quaternion
a new quaternion as the subtraction result of the given one from the current one
- other: DeepImmutable<this>
subtract From Floats
-
Subtracts the given floats from the current quaternion
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
Returns Quaternion
a new quaternion as the subtraction result
- x: number
subtract From Floats To Ref
-
subtractFromFloatsToRef<T extends Quaternion>(
x: number,
y: number,
z: number,
w: number,
result: T,
): TSubtracts the given floats from the current quaternion and stores the result in the given one
Type Parameters
- T extends Quaternion
Parameters
- x: number
defines the x coordinate
- y: number
defines the y coordinate
- z: number
defines the z coordinate
- w: number
defines the w coordinate
- result: T
defines the quaternion to store the result
Returns T
result input
subtract In Place
-
Subtract a quaternion to the current one Example Playground https://playground.babylonjs.com/#L49EJ7#58
Parameters
- other: DeepImmutable<Quaternion>
defines the quaternion to subtract
Returns this
the current quaternion
- other: DeepImmutable<Quaternion>
subtract To Ref
-
Sets the "result" coordinates with the subtraction of the other's coordinates from the current coordinates.
Type Parameters
- T extends Quaternion
Parameters
- other: DeepImmutable<this>
defines the other instance
- result: T
defines the target instance
Returns T
result input
to Alpha Beta Gamma To Ref
to Array
-
Stores from the starting index in the given array the Quaternion successive values Example Playground https://playground.babylonjs.com/#L49EJ7#59
Parameters
- array: FloatArray
defines the array where to store the x,y,z,w components
- index: number = 0
defines an optional index in the target array to define where to start storing values
Returns this
the current Quaternion object
- array: FloatArray
to Axis Angle
-
Converts the current quaternion to an axis angle representation
Returns { angle: number; axis: Vector3 }
the axis and angle in radians
to Axis Angle To Ref
to Euler Angles
-
Returns a new Vector3 set with the Euler angles translated from the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#32
Returns Vector3
a new Vector3 containing the Euler angles
to Euler Angles To Ref
-
Sets the given vector3 "result" with the Euler angles translated from the current quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#31
Type Parameters
- T extends Vector3
Parameters
- result: T
defines the vector which will be filled with the Euler angles
Returns T
result input
to Rotation Matrix
-
Updates the given rotation matrix with the current quaternion values Example Playground https://playground.babylonjs.com/#L49EJ7#67
Type Parameters
- T extends Matrix
Parameters
- result: T
defines the target matrix
Returns T
the updated matrix with the rotation
to String
-
Gets a string representation for the current quaternion
Returns string
a string with the Quaternion coordinates
StaticAre Close
-
AreClose(
quat0: DeepImmutable<Quaternion>,
quat1: DeepImmutable<Quaternion>,
epsilon?: number,
): booleanChecks if the orientations of two rotation quaternions are close to each other Example Playground https://playground.babylonjs.com/#L49EJ7#60
Parameters
- quat0: DeepImmutable<Quaternion>
defines the first quaternion to check
- quat1: DeepImmutable<Quaternion>
defines the second quaternion to check
- epsilon: number = 0.1
defines closeness, 0 same orientation, 1 PI apart, default 0.1
Returns boolean
true if the two quaternions are close to each other within epsilon
- quat0: DeepImmutable<Quaternion>
StaticCenter
-
Returns a new Quaternion located at the center between the quaternions "value1" and "value2".
Parameters
- value1: DeepImmutable<Quaternion>
value to calulate the center between
- value2: DeepImmutable<Quaternion>
value to calulate the center between
Returns Quaternion
the center between the two quaternions
- value1: DeepImmutable<Quaternion>
StaticCenter To Ref
-
CenterToRef<T extends Quaternion>(
value1: DeepImmutable<Quaternion>,
value2: DeepImmutable<Quaternion>,
ref: T,
): TGets the center of the quaternions "value1" and "value2" and stores the result in the quaternion "ref"
Type Parameters
- T extends Quaternion
Parameters
- value1: DeepImmutable<Quaternion>
defines first quaternion
- value2: DeepImmutable<Quaternion>
defines second quaternion
- ref: T
defines third quaternion
Returns T
ref
StaticClamp
-
Clamp(
value: DeepImmutable<Quaternion>,
min: DeepImmutable<Quaternion>,
max: DeepImmutable<Quaternion>,
): QuaternionReturns a new Quaternion set with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max" If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
Parameters
- value: DeepImmutable<Quaternion>
defines the current value
- min: DeepImmutable<Quaternion>
defines the lower range value
- max: DeepImmutable<Quaternion>
defines the upper range value
Returns Quaternion
the new Quaternion
- value: DeepImmutable<Quaternion>
StaticClamp To Ref
-
ClampToRef<T extends Quaternion>(
value: DeepImmutable<Quaternion>,
min: DeepImmutable<Quaternion>,
max: DeepImmutable<Quaternion>,
result: T,
): TSets the given quaternion "result" with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max" If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
Type Parameters
- T extends Quaternion
Parameters
- value: DeepImmutable<Quaternion>
defines the current value
- min: DeepImmutable<Quaternion>
defines the lower range value
- max: DeepImmutable<Quaternion>
defines the upper range value
- result: T
defines the Quaternion where to store the result
Returns T
result input
StaticDistance
-
Returns the distance (float) between the quaternions "value1" and "value2".
Parameters
- value1: DeepImmutable<Quaternion>
value to calulate the distance between
- value2: DeepImmutable<Quaternion>
value to calulate the distance between
Returns number
the distance between the two quaternions
- value1: DeepImmutable<Quaternion>
StaticDistance Squared
-
Returns the squared distance (float) between the quaternions "value1" and "value2".
Parameters
- value1: DeepImmutable<Quaternion>
value to calulate the distance between
- value2: DeepImmutable<Quaternion>
value to calulate the distance between
Returns number
the distance between the two quaternions squared
- value1: DeepImmutable<Quaternion>
StaticDot
-
Returns the dot product (float) between the quaternions "left" and "right" Example Playground https://playground.babylonjs.com/#L49EJ7#61
Parameters
- left: DeepImmutable<Quaternion>
defines the left operand
- right: DeepImmutable<Quaternion>
defines the right operand
Returns number
the dot product
- left: DeepImmutable<Quaternion>
StaticFrom Array
-
Creates a new quaternion from data stored into an array Example Playground https://playground.babylonjs.com/#L49EJ7#63
Parameters
- array: DeepImmutable<ArrayLike<number>>
defines the data source
Optionaloffset: numberdefines the offset in the source array where the data starts
Returns Quaternion
a new quaternion
- array: DeepImmutable<ArrayLike<number>>
StaticFrom Array To Ref
-
FromArrayToRef<T extends Quaternion>(
array: DeepImmutable<ArrayLike<number>>,
offset: number,
result: T,
): TUpdates the given quaternion "result" from the starting index of the given array. Example Playground https://playground.babylonjs.com/#L49EJ7#64
Type Parameters
- T extends Quaternion
Parameters
- array: DeepImmutable<ArrayLike<number>>
the array to pull values from
- offset: number
the offset into the array to start at
- result: T
the quaternion to store the result in
Returns T
result input
StaticFrom Euler Angles
-
Create a quaternion from Euler rotation angles Example Playground https://playground.babylonjs.com/#L49EJ7#33
Parameters
- x: number
Pitch
- y: number
Yaw
- z: number
Roll
Returns Quaternion
the new Quaternion
- x: number
StaticFrom Euler Angles To Ref
-
Updates a quaternion from Euler rotation angles Example Playground https://playground.babylonjs.com/#L49EJ7#34
Type Parameters
- T extends Quaternion
Parameters
- x: number
Pitch
- y: number
Yaw
- z: number
Roll
- result: T
the quaternion to store the result
Returns T
the updated quaternion
StaticFrom Euler Vector
-
Create a quaternion from Euler rotation vector Example Playground https://playground.babylonjs.com/#L49EJ7#35
Parameters
- vec: DeepImmutable<Vector3>
the Euler vector (x Pitch, y Yaw, z Roll)
Returns Quaternion
the new Quaternion
- vec: DeepImmutable<Vector3>
StaticFrom Euler Vector To Ref
-
Updates a quaternion from Euler rotation vector Example Playground https://playground.babylonjs.com/#L49EJ7#36
Type Parameters
- T extends Quaternion
Parameters
- vec: DeepImmutable<Vector3>
the Euler vector (x Pitch, y Yaw, z Roll)
- result: T
the quaternion to store the result
Returns T
the updated quaternion
StaticFrom Floats To Ref
-
FromFloatsToRef<T extends Quaternion = Quaternion>(
x: number,
y: number,
z: number,
w: number,
result: T,
): TSets the given quaternion "result" with the given floats.
Type Parameters
- T extends Quaternion = Quaternion
Parameters
- x: number
defines the x coordinate of the source
- y: number
defines the y coordinate of the source
- z: number
defines the z coordinate of the source
- w: number
defines the w coordinate of the source
- result: T
defines the quaternion where to store the result
Returns T
the result quaternion
StaticFrom Look Direction LH
-
Creates a new rotation value to orient an object to look towards the given forward direction, the up direction being oriented like "up". This function works in left handed mode Example Playground https://playground.babylonjs.com/#L49EJ7#96
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Quaternion
A new quaternion oriented toward the specified forward and up.
- forward: DeepImmutable<Vector3>
StaticFrom Look Direction LH To Ref
-
FromLookDirectionLHToRef<T extends Quaternion>(
forward: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
ref: T,
): TCreates a new rotation value to orient an object to look towards the given forward direction with the up direction being oriented like "up", and stores it in the target quaternion. This function works in left handed mode Example Playground https://playground.babylonjs.com/#L49EJ7#97
Type Parameters
- T extends Quaternion
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
- ref: T
defines the target quaternion.
Returns T
result input
StaticFrom Look Direction RH
-
Creates a new rotation value to orient an object to look towards the given forward direction, the up direction being oriented like "up". This function works in right handed mode Example Playground https://playground.babylonjs.com/#L49EJ7#98
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Quaternion
A new quaternion oriented toward the specified forward and up.
- forward: DeepImmutable<Vector3>
StaticFrom Look Direction RH To Ref
-
FromLookDirectionRHToRef<T extends Quaternion>(
forward: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
ref: T,
): TCreates a new rotation value to orient an object to look towards the given forward direction with the up direction being oriented like "up", and stores it in the target quaternion. This function works in right handed mode Example Playground https://playground.babylonjs.com/#L49EJ7#105
Type Parameters
- T extends Quaternion
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
- ref: T
defines the target quaternion.
Returns T
result input
StaticFrom Rotation Matrix
-
Creates a new quaternion from a rotation matrix Example Playground https://playground.babylonjs.com/#L49EJ7#101
Parameters
- matrix: DeepImmutable<Matrix>
defines the source matrix
Returns Quaternion
a new quaternion created from the given rotation matrix values
- matrix: DeepImmutable<Matrix>
StaticFrom Rotation Matrix To Ref
-
Updates the given quaternion with the given rotation matrix values Example Playground https://playground.babylonjs.com/#L49EJ7#102
Type Parameters
- T extends Quaternion
Parameters
- matrix: DeepImmutable<Matrix>
defines the source matrix
- result: T
defines the target quaternion
Returns T
result input
StaticFrom Unit Vectors To Ref
-
FromUnitVectorsToRef<T extends Quaternion>(
vecFrom: DeepImmutable<Vector3>,
vecTo: DeepImmutable<Vector3>,
result: T,
epsilon?: number,
): TUpdates a quaternion so that it rotates vector vecFrom to vector vecTo Example Playground - https://playground.babylonjs.com/#L49EJ7#70
Type Parameters
- T extends Quaternion
Parameters
- vecFrom: DeepImmutable<Vector3>
defines the direction vector from which to rotate
- vecTo: DeepImmutable<Vector3>
defines the direction vector to which to rotate
- result: T
the quaternion to store the result
- epsilon: number = Epsilon
defines the minimal dot value to define vecs as opposite. Default:
BABYLON.Epsilon
Returns T
the updated quaternion
StaticHermite
-
Hermite(
value1: DeepImmutable<Quaternion>,
tangent1: DeepImmutable<Quaternion>,
value2: DeepImmutable<Quaternion>,
tangent2: DeepImmutable<Quaternion>,
amount: number,
): QuaternionInterpolate between two quaternions using Hermite interpolation Example Playground https://playground.babylonjs.com/#L49EJ7#47
Parameters
- value1: DeepImmutable<Quaternion>
defines first quaternion
- tangent1: DeepImmutable<Quaternion>
defines the incoming tangent
- value2: DeepImmutable<Quaternion>
defines second quaternion
- tangent2: DeepImmutable<Quaternion>
defines the outgoing tangent
- amount: number
defines the target quaternion
Returns Quaternion
the new interpolated quaternion
- value1: DeepImmutable<Quaternion>
StaticHermite1st Derivative
-
Hermite1stDerivative(
value1: DeepImmutable<Quaternion>,
tangent1: DeepImmutable<Quaternion>,
value2: DeepImmutable<Quaternion>,
tangent2: DeepImmutable<Quaternion>,
time: number,
): QuaternionReturns a new Quaternion which is the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2". Example Playground https://playground.babylonjs.com/#L49EJ7#48
Parameters
- value1: DeepImmutable<Quaternion>
defines the first control point
- tangent1: DeepImmutable<Quaternion>
defines the first tangent
- value2: DeepImmutable<Quaternion>
defines the second control point
- tangent2: DeepImmutable<Quaternion>
defines the second tangent
- time: number
define where the derivative must be done
Returns Quaternion
1st derivative
- value1: DeepImmutable<Quaternion>
StaticHermite1st Derivative To Ref
-
Hermite1stDerivativeToRef<T extends Quaternion>(
value1: DeepImmutable<Quaternion>,
tangent1: DeepImmutable<Quaternion>,
value2: DeepImmutable<Quaternion>,
tangent2: DeepImmutable<Quaternion>,
time: number,
result: T,
): TUpdate a Quaternion with the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2". Example Playground https://playground.babylonjs.com/#L49EJ7#49
Type Parameters
- T extends Quaternion
Parameters
- value1: DeepImmutable<Quaternion>
defines the first control point
- tangent1: DeepImmutable<Quaternion>
defines the first tangent
- value2: DeepImmutable<Quaternion>
defines the second control point
- tangent2: DeepImmutable<Quaternion>
defines the second tangent
- time: number
define where the derivative must be done
- result: T
define where to store the derivative
Returns T
result input
StaticIdentity
StaticInverse
-
Inverse a given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#103
Parameters
- q: DeepImmutable<Quaternion>
defines the source quaternion
Returns Quaternion
a new quaternion as the inverted current quaternion
- q: DeepImmutable<Quaternion>
StaticInverse To Ref
-
Inverse a given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#104
Type Parameters
- T extends Quaternion
Parameters
- q: Quaternion
defines the source quaternion
- result: T
the quaternion the result will be stored in
Returns T
the result quaternion
StaticIs Identity
-
Gets a boolean indicating if the given quaternion is identity
Parameters
- quaternion: DeepImmutable<Quaternion>
defines the quaternion to check
Returns boolean
true if the quaternion is identity
- quaternion: DeepImmutable<Quaternion>
StaticNormalize
-
Returns a new Quaternion as the normalization of the given Quaternion
Parameters
- quat: DeepImmutable<Quaternion>
defines the Quaternion to normalize
Returns Quaternion
the new Quaternion
- quat: DeepImmutable<Quaternion>
StaticNormalize To Ref
-
Sets the given Quaternion "result" with the normalization of the given first Quaternion
Type Parameters
- T extends Quaternion
Parameters
- quat: DeepImmutable<Quaternion>
defines the Quaternion to normalize
- result: T
defines the Quaternion where to store the result
Returns T
result input
StaticRandom
-
Returns a new Quaternion with random values between min and max
Parameters
- min: number = 0
the minimum random value
- max: number = 1
the maximum random value
Returns Quaternion
a Quaternion with random values between min and max
- min: number = 0
StaticRandom To Ref
-
Sets a Quaternion with random values between min and max
Type Parameters
- T extends Quaternion
Parameters
- min: number = 0
the minimum random value
- max: number = 1
the maximum random value
- ref: T
the ref to store the values in
Returns T
the ref with random values between min and max
StaticRotation Alpha Beta Gamma
-
Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation Example Playground https://playground.babylonjs.com/#L49EJ7#68
Parameters
- alpha: number
defines the rotation around first axis
- beta: number
defines the rotation around second axis
- gamma: number
defines the rotation around third axis
Returns Quaternion
the new quaternion
- alpha: number
StaticRotation Alpha Beta Gamma To Ref
-
RotationAlphaBetaGammaToRef<T extends Quaternion>(
alpha: number,
beta: number,
gamma: number,
result: T,
): TCreates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#69
Type Parameters
- T extends Quaternion
Parameters
- alpha: number
defines the rotation around first axis
- beta: number
defines the rotation around second axis
- gamma: number
defines the rotation around third axis
- result: T
defines the target quaternion
Returns T
result input
StaticRotation Axis
-
Creates a quaternion from a rotation around an axis Example Playground https://playground.babylonjs.com/#L49EJ7#72
Parameters
- axis: DeepImmutable<Vector3>
defines the axis to use
- angle: number
defines the angle to use
Returns Quaternion
a new quaternion created from the given axis (Vector3) and angle in radians (float)
- axis: DeepImmutable<Vector3>
StaticRotation Axis To Ref
-
RotationAxisToRef<T extends Quaternion>(
axis: DeepImmutable<Vector3>,
angle: number,
result: T,
): TCreates a rotation around an axis and stores it into the given quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#73
Type Parameters
- T extends Quaternion
Parameters
- axis: DeepImmutable<Vector3>
defines the axis to use
- angle: number
defines the angle to use
- result: T
defines the target quaternion
Returns T
the target quaternion
StaticRotation Quaternion From Axis
-
RotationQuaternionFromAxis(
axis1: DeepImmutable<Vector3>,
axis2: DeepImmutable<Vector3>,
axis3: DeepImmutable<Vector3>,
): QuaternionCreates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) Example Playground https://playground.babylonjs.com/#L49EJ7#75
Parameters
- axis1: DeepImmutable<Vector3>
defines the first axis
- axis2: DeepImmutable<Vector3>
defines the second axis
- axis3: DeepImmutable<Vector3>
defines the third axis
Returns Quaternion
the new quaternion
- axis1: DeepImmutable<Vector3>
StaticRotation Quaternion From Axis To Ref
-
RotationQuaternionFromAxisToRef<T extends Quaternion>(
axis1: DeepImmutable<Vector3>,
axis2: DeepImmutable<Vector3>,
axis3: DeepImmutable<Vector3>,
ref: T,
): TCreates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#76
Type Parameters
- T extends Quaternion
Parameters
- axis1: DeepImmutable<Vector3>
defines the first axis
- axis2: DeepImmutable<Vector3>
defines the second axis
- axis3: DeepImmutable<Vector3>
defines the third axis
- ref: T
defines the target quaternion
Returns T
result input
StaticRotation Yaw Pitch Roll
-
Creates a new quaternion from the given Euler float angles (y, x, z) Example Playground https://playground.babylonjs.com/#L49EJ7#77
Parameters
- yaw: number
defines the rotation around Y axis
- pitch: number
defines the rotation around X axis
- roll: number
defines the rotation around Z axis
Returns Quaternion
the new quaternion
- yaw: number
StaticRotation Yaw Pitch Roll To Ref
-
RotationYawPitchRollToRef<T extends Quaternion>(
yaw: number,
pitch: number,
roll: number,
result: T,
): TCreates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#561
Type Parameters
- T extends Quaternion
Parameters
- yaw: number
defines the rotation around Y axis
- pitch: number
defines the rotation around X axis
- roll: number
defines the rotation around Z axis
- result: T
defines the target quaternion
Returns T
result input
StaticSlerp
-
Slerp(
left: DeepImmutable<Quaternion>,
right: DeepImmutable<Quaternion>,
amount: number,
): QuaternionInterpolates between two quaternions Example Playground https://playground.babylonjs.com/#L49EJ7#79
Parameters
- left: DeepImmutable<Quaternion>
defines first quaternion
- right: DeepImmutable<Quaternion>
defines second quaternion
- amount: number
defines the gradient to use
Returns Quaternion
the new interpolated quaternion
- left: DeepImmutable<Quaternion>
StaticSlerp To Ref
-
SlerpToRef<T extends Quaternion>(
left: DeepImmutable<Quaternion>,
right: DeepImmutable<Quaternion>,
amount: number,
result: T,
): TInterpolates between two quaternions and stores it into a target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#92
Type Parameters
- T extends Quaternion
Parameters
- left: DeepImmutable<Quaternion>
defines first quaternion
- right: DeepImmutable<Quaternion>
defines second quaternion
- amount: number
defines the gradient to use
- result: T
defines the target quaternion
Returns T
result input
StaticSmooth To Ref
-
SmoothToRef<T extends Quaternion>(
source: Quaternion,
goal: Quaternion,
deltaTime: number,
lerpTime: number,
result: T,
): TSmooth interpolation between two quaternions using Slerp Example Playground https://playground.babylonjs.com/#L49EJ7#93
Type Parameters
- T extends Quaternion
Parameters
- source: Quaternion
source quaternion
- goal: Quaternion
goal quaternion
- deltaTime: number
current interpolation frame
- lerpTime: number
total interpolation time
- result: T
the smoothed quaternion
Returns T
the smoothed quaternion
Class used to store quaternion data Example Playground - Overview - https://playground.babylonjs.com/#L49EJ7#100
See