Class Quaternion
Hierarchy
- Quaternion
Index
Constructors
Accessors
Methods
- add
- add
In Place - as
Array - clone
- conjugate
- conjugate
In Place - conjugate
To Ref - copy
From - copy
From Floats - equals
- equals
With Epsilon - from
Rotation Matrix - get
Class Name - get
Hash Code - invert
- invert
In Place - length
- length
Squared - multiply
- multiply
In Place - multiply
To Ref - normalize
- normalize
To New - scale
- scale
And Add To Ref - scale
In Place - scale
To Ref - set
- subtract
- subtract
In Place - to
Array - to
Euler Angles - to
Euler Angles To Ref - to
Rotation Matrix - to
String - Are
Close - Dot
- From
Array - From
Array To Ref - From
Euler Angles - From
Euler Angles To Ref - From
Euler Vector - From
Euler Vector To Ref - From
Look DirectionLH - From
Look DirectionLHTo Ref - From
Look DirectionRH - From
Look DirectionRHTo Ref - From
Rotation Matrix - From
Rotation Matrix To Ref - From
Unit Vectors To Ref - Hermite
- Hermite1st
Derivative - Hermite1st
Derivative To Ref - Identity
- Inverse
- Inverse
To Ref - Is
Identity - Rotation
Alpha Beta Gamma - Rotation
Alpha Beta Gamma To Ref - Rotation
Axis - Rotation
Axis To Ref - Rotation
Quaternion From Axis - Rotation
Quaternion From Axis To Ref - Rotation
Quaternion From Onto - Rotation
Quaternion From Onto To Ref - Rotation
Yaw Pitch Roll - Rotation
Yaw Pitch Roll To Ref - Slerp
- Slerp
To Ref - Smooth
To Ref - Zero
Constructors
constructor
Creates a new Quaternion from the given floats
Parameters
Optional x: number
defines the first component (0 by default)
Optional y: number
defines the second component (0 by default)
Optional z: number
defines the third component (0 by default)
Optional w: number
defines the fourth component (1.0 by default)
Returns Quaternion
Accessors
w
Gets or sets the w coordinate
Returns number
Gets or sets the w coordinate
Parameters
value: number
Returns void
x
Gets or sets the x coordinate
Returns number
Gets or sets the x coordinate
Parameters
value: number
Returns void
y
Gets or sets the y coordinate
Returns number
Gets or sets the y coordinate
Parameters
value: number
Returns void
z
Gets or sets the z coordinate
Returns number
Gets or sets the z coordinate
Parameters
value: number
Returns void
Methods
addSearch playground for add
Adds two quaternions
Parameters
other: DeepImmutableObject<Quaternion>
defines the second operand
Returns Quaternion
a new quaternion as the addition result of the given one and the current quaternion
add In PlaceSearch playground for addInPlace
Add a quaternion to the current one
Parameters
other: DeepImmutableObject<Quaternion>
defines the quaternion to add
Returns Quaternion
the current quaternion
as ArraySearch playground for asArray
Copy the quaternion to an array
Returns number[]
a new array populated with 4 elements from the quaternion coordinates
cloneSearch playground for clone
Clone the current quaternion
Returns Quaternion
a new quaternion copied from the current one
conjugateSearch playground for conjugate
Conjugates (1-q) the current quaternion
Returns Quaternion
a new quaternion
conjugate In PlaceSearch playground for conjugateInPlace
Conjugates in place the current quaternion
Returns Quaternion
the current updated quaternion
conjugate To RefSearch playground for conjugateToRef
Conjugates the current quaternion and stores the result in the given quaternion
Parameters
ref: Quaternion
defines the target quaternion
Returns Quaternion
the current quaternion
copy FromSearch playground for copyFrom
Copy a quaternion to the current one
Parameters
other: DeepImmutableObject<Quaternion>
defines the other quaternion
Returns Quaternion
the updated current quaternion
copy From FloatsSearch playground for copyFromFloats
Updates the current quaternion with the given float coordinates
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
the updated current quaternion
equalsSearch playground for equals
Check if two quaternions are equals
Parameters
otherQuaternion: DeepImmutableObject<Quaternion>
defines the second operand
Returns boolean
true if the current quaternion and the given one coordinates are strictly equals
equals With EpsilonSearch playground for equalsWithEpsilon
Gets a boolean if two quaternions are equals (using an epsilon value)
Parameters
otherQuaternion: DeepImmutableObject<Quaternion>
defines the other quaternion
Optional epsilon: number
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.
from Rotation MatrixSearch playground for fromRotationMatrix
Updates the current quaternion from the given rotation matrix values
Parameters
matrix: DeepImmutableObject<Matrix>
defines the source matrix
Returns Quaternion
the current updated quaternion
get Class NameSearch playground for getClassName
Gets the class name of the quaternion
Returns string
the string "Quaternion"
get Hash CodeSearch playground for getHashCode
Gets a hash code for this quaternion
Returns number
the quaternion hash code
invertSearch playground for invert
Returns the inverse of the current quaternion
Returns Quaternion
a new quaternion
invert In PlaceSearch playground for invertInPlace
Invert in place the current quaternion
Returns Quaternion
this quaternion
lengthSearch playground for length
Gets length of current quaternion
Returns number
the quaternion length (float)
length SquaredSearch playground for lengthSquared
Gets squared length of current quaternion
Returns number
the quaternion length (float)
multiplySearch playground for multiply
Multiplies two quaternions
Parameters
q1: DeepImmutableObject<Quaternion>
defines the second operand
Returns Quaternion
a new quaternion set as the multiplication result of the current one with the given one "q1"
multiply In PlaceSearch playground for multiplyInPlace
Updates the current quaternion with the multiplication of itself with the given one "q1"
Parameters
q1: DeepImmutableObject<Quaternion>
defines the second operand
Returns Quaternion
the currentupdated quaternion
multiply To RefSearch playground for multiplyToRef
Sets the given "result" as the the multiplication result of the current one with the given one "q1"
Parameters
q1: DeepImmutableObject<Quaternion>
defines the second operand
result: Quaternion
defines the target quaternion
Returns Quaternion
the current quaternion
normalizeSearch playground for normalize
Normalize in place the current quaternion
Returns Quaternion
the current updated quaternion
normalize To NewSearch playground for normalizeToNew
Normalize a copy of the current quaternion
Returns Quaternion
the normalized quaternion
scaleSearch playground for scale
Multiplies the current quaternion by a scale factor
Parameters
value: number
defines the scale factor
Returns Quaternion
a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
scale And Add To RefSearch playground for scaleAndAddToRef
Scale the current quaternion values by a factor and add the result to a given quaternion
Parameters
scale: number
defines the scale factor
result: Quaternion
defines the Quaternion object where to store the result
Returns Quaternion
the unmodified current quaternion
scale In PlaceSearch playground for scaleInPlace
Multiplies in place the current quaternion by a scale factor
Parameters
value: number
defines the scale factor
Returns Quaternion
the current modified quaternion
scale To RefSearch playground for scaleToRef
Scale the current quaternion values by a factor and stores the result to a given quaternion
Parameters
scale: number
defines the scale factor
result: Quaternion
defines the Quaternion object where to store the result
Returns Quaternion
the unmodified current quaternion
setSearch playground for set
Updates the current quaternion from the given float coordinates
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
the updated current quaternion
subtractSearch playground for subtract
Subtract two quaternions
Parameters
other: Quaternion
defines the second operand
Returns Quaternion
a new quaternion as the subtraction result of the given one from the current one
subtract In PlaceSearch playground for subtractInPlace
Subtract a quaternion to the current one
Parameters
other: DeepImmutableObject<Quaternion>
defines the quaternion to subtract
Returns Quaternion
the current quaternion
to ArraySearch playground for toArray
Stores from the starting index in the given array the Quaternion successive values
Parameters
array: FloatArray
defines the array where to store the x,y,z,w components
Optional index: number
defines an optional index in the target array to define where to start storing values
Returns Quaternion
the current Quaternion object
to Euler AnglesSearch playground for toEulerAngles
Returns a new Vector3 set with the Euler angles translated from the current quaternion
Returns Vector3
a new Vector3 containing the Euler angles
to Euler Angles To RefSearch playground for toEulerAnglesToRef
Sets the given vector3 "result" with the Euler angles translated from the current quaternion
Parameters
result: Vector3
defines the vector which will be filled with the Euler angles
Returns Quaternion
the current unchanged quaternion
to Rotation MatrixSearch playground for toRotationMatrix
Updates the given rotation matrix with the current quaternion values
Parameters
result: Matrix
defines the target matrix
Returns Quaternion
the current unchanged quaternion
to StringSearch playground for toString
Gets a string representation for the current quaternion
Returns string
a string with the Quaternion coordinates
Static Are CloseSearch playground for AreClose
Checks if the orientations of two rotation quaternions are close to each other
Parameters
quat0: DeepImmutableObject<Quaternion>
defines the first quaternion to check
quat1: DeepImmutableObject<Quaternion>
defines the second quaternion to check
Optional epsilon: number
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
Static DotSearch playground for Dot
Returns the dot product (float) between the quaternions "left" and "right"
Parameters
left: DeepImmutableObject<Quaternion>
defines the left operand
right: DeepImmutableObject<Quaternion>
defines the right operand
Returns number
the dot product
Static From ArraySearch playground for FromArray
Creates a new quaternion from data stored into an array
Parameters
array: DeepImmutableObject<ArrayLike<number>>
defines the data source
Optional offset: number
defines the offset in the source array where the data starts
Returns Quaternion
a new quaternion
Static From Array To RefSearch playground for FromArrayToRef
Updates the given quaternion "result" from the starting index of the given array.
Parameters
array: DeepImmutableObject<ArrayLike<number>>
the array to pull values from
offset: number
the offset into the array to start at
result: Quaternion
the quaternion to store the result in
Returns void
Static From Euler AnglesSearch playground for FromEulerAngles
Create a quaternion from Euler rotation angles
Parameters
x: number
Pitch
y: number
Yaw
z: number
Roll
Returns Quaternion
the new Quaternion
Static From Euler Angles To RefSearch playground for FromEulerAnglesToRef
Updates a quaternion from Euler rotation angles
Parameters
x: number
Pitch
y: number
Yaw
z: number
Roll
result: Quaternion
the quaternion to store the result
Returns Quaternion
the updated quaternion
Static From Euler VectorSearch playground for FromEulerVector
Create a quaternion from Euler rotation vector
Parameters
vec: DeepImmutableObject<Vector3>
the Euler vector (x Pitch, y Yaw, z Roll)
Returns Quaternion
the new Quaternion
Static From Euler Vector To RefSearch playground for FromEulerVectorToRef
Updates a quaternion from Euler rotation vector
Parameters
vec: DeepImmutableObject<Vector3>
the Euler vector (x Pitch, y Yaw, z Roll)
result: Quaternion
the quaternion to store the result
Returns Quaternion
the updated quaternion
Static From Look DirectionLHSearch playground for FromLookDirectionLH
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
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<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.
Static From Look DirectionLHTo RefSearch playground for FromLookDirectionLHToRef
Creates 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
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
ref: Quaternion
defines the target quaternion.
Returns void
Static From Look DirectionRHSearch playground for FromLookDirectionRH
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
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<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.
Static From Look DirectionRHTo RefSearch playground for FromLookDirectionRHToRef
Creates 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
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
ref: Quaternion
defines the target quaternion.
Returns void
Static From Rotation MatrixSearch playground for FromRotationMatrix
Creates a new quaternion from a rotation matrix
Parameters
matrix: DeepImmutableObject<Matrix>
defines the source matrix
Returns Quaternion
a new quaternion created from the given rotation matrix values
Static From Rotation Matrix To RefSearch playground for FromRotationMatrixToRef
Updates the given quaternion with the given rotation matrix values
Parameters
matrix: DeepImmutableObject<Matrix>
defines the source matrix
result: Quaternion
defines the target quaternion
Returns void
Static From Unit Vectors To RefSearch playground for FromUnitVectorsToRef
Updates a quaternion so that it rotates vector vecFrom to vector vecTo
Parameters
vecFrom: DeepImmutableObject<Vector3>
defines the direction vector from which to rotate
vecTo: DeepImmutableObject<Vector3>
defines the direction vector to which to rotate
result: Quaternion
the quaternion to store the result
Returns Quaternion
the updated quaternion
Static HermiteSearch playground for Hermite
Interpolate between two quaternions using Hermite interpolation
Parameters
value1: DeepImmutableObject<Quaternion>
defines first quaternion
tangent1: DeepImmutableObject<Quaternion>
defines the incoming tangent
value2: DeepImmutableObject<Quaternion>
defines second quaternion
tangent2: DeepImmutableObject<Quaternion>
defines the outgoing tangent
amount: number
defines the target quaternion
Returns Quaternion
the new interpolated quaternion
Static Hermite1st DerivativeSearch playground for Hermite1stDerivative
Returns a new Quaternion which is the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2".
Parameters
value1: DeepImmutableObject<Quaternion>
defines the first control point
tangent1: DeepImmutableObject<Quaternion>
defines the first tangent
value2: DeepImmutableObject<Quaternion>
defines the second control point
tangent2: DeepImmutableObject<Quaternion>
defines the second tangent
time: number
define where the derivative must be done
Returns Quaternion
1st derivative
Static Hermite1st Derivative To RefSearch playground for Hermite1stDerivativeToRef
Update a Quaternion with the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2".
Parameters
value1: DeepImmutableObject<Quaternion>
defines the first control point
tangent1: DeepImmutableObject<Quaternion>
defines the first tangent
value2: DeepImmutableObject<Quaternion>
defines the second control point
tangent2: DeepImmutableObject<Quaternion>
defines the second tangent
time: number
define where the derivative must be done
result: Quaternion
define where to store the derivative
Returns void
Static IdentitySearch playground for Identity
Creates an identity quaternion
Returns Quaternion
the identity quaternion
Static InverseSearch playground for Inverse
Inverse a given quaternion
Parameters
q: DeepImmutableObject<Quaternion>
defines the source quaternion
Returns Quaternion
a new quaternion as the inverted current quaternion
Static Inverse To RefSearch playground for InverseToRef
Inverse a given quaternion
Parameters
q: Quaternion
defines the source quaternion
result: Quaternion
the quaternion the result will be stored in
Returns Quaternion
the result quaternion
Static Is IdentitySearch playground for IsIdentity
Gets a boolean indicating if the given quaternion is identity
Parameters
quaternion: DeepImmutableObject<Quaternion>
defines the quaternion to check
Returns boolean
true if the quaternion is identity
Static Rotation Alpha Beta GammaSearch playground for RotationAlphaBetaGamma
Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
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
Static Rotation Alpha Beta Gamma To RefSearch playground for RotationAlphaBetaGammaToRef
Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target 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: Quaternion
defines the target quaternion
Returns void
Static Rotation AxisSearch playground for RotationAxis
Creates a quaternion from a rotation around an axis
Parameters
axis: DeepImmutableObject<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)
Static Rotation Axis To RefSearch playground for RotationAxisToRef
Creates a rotation around an axis and stores it into the given quaternion
Parameters
axis: DeepImmutableObject<Vector3>
defines the axis to use
angle: number
defines the angle to use
result: Quaternion
defines the target quaternion
Returns Quaternion
the target quaternion
Static Rotation Quaternion From AxisSearch playground for RotationQuaternionFromAxis
Creates 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)
Parameters
axis1: DeepImmutableObject<Vector3>
defines the first axis
axis2: DeepImmutableObject<Vector3>
defines the second axis
axis3: DeepImmutableObject<Vector3>
defines the third axis
Returns Quaternion
the new quaternion
Static Rotation Quaternion From Axis To RefSearch playground for RotationQuaternionFromAxisToRef
Creates 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
Parameters
axis1: DeepImmutableObject<Vector3>
defines the first axis
axis2: DeepImmutableObject<Vector3>
defines the second axis
axis3: DeepImmutableObject<Vector3>
defines the third axis
ref: Quaternion
defines the target quaternion
Returns void
Static Rotation Quaternion From OntoSearch playground for RotationQuaternionFromOnto
Creates the rotation quaternion needed to rotate from one Vector3 onto another Vector3 Example PG https://playground.babylonjs.com/#L49EJ7#2
Parameters
fromVector: DeepImmutableObject<Vector3>
the starting vector
toVector: DeepImmutableObject<Vector3>
the ending vector
Returns Quaternion
the rotation quaternion needed
Static Rotation Quaternion From Onto To RefSearch playground for RotationQuaternionFromOntoToRef
Creates the rotation quaternion needed to rotate from one Vector3 onto another Vector3 and stores in a result Quaternion Example PG https://playground.babylonjs.com/#L49EJ7#3
Parameters
fromVector: DeepImmutableObject<Vector3>
the starting vector
toVector: DeepImmutableObject<Vector3>
the ending vector
result: DeepImmutableObject<Quaternion>
the rotation quaternion needed
Returns Quaternion
the result
Static Rotation Yaw Pitch RollSearch playground for RotationYawPitchRoll
Creates a new quaternion from the given Euler float angles (y, x, z)
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
Static Rotation Yaw Pitch Roll To RefSearch playground for RotationYawPitchRollToRef
Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target 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: Quaternion
defines the target quaternion
Returns void
Static SlerpSearch playground for Slerp
Interpolates between two quaternions
Parameters
left: DeepImmutableObject<Quaternion>
defines first quaternion
right: DeepImmutableObject<Quaternion>
defines second quaternion
amount: number
defines the gradient to use
Returns Quaternion
the new interpolated quaternion
Static Slerp To RefSearch playground for SlerpToRef
Interpolates between two quaternions and stores it into a target quaternion
Parameters
left: DeepImmutableObject<Quaternion>
defines first quaternion
right: DeepImmutableObject<Quaternion>
defines second quaternion
amount: number
defines the gradient to use
result: Quaternion
defines the target quaternion
Returns void
Static Smooth To RefSearch playground for SmoothToRef
Smooth interpolation between two quaternions using Slerp
Parameters
source: Quaternion
source quaternion
goal: Quaternion
goal quaternion
deltaTime: number
current interpolation frame
lerpTime: number
total interpolation time
result: Quaternion
the smoothed quaternion
Returns void
Static ZeroSearch playground for Zero
Creates an empty quaternion
Returns Quaternion
a new quaternion set to (0.0, 0.0, 0.0)
Class used to store quaternion data
https://en.wikipedia.org/wiki/Quaternion
https://doc.babylonjs.com/features/position,_rotation,_scaling