Class Quaternion
- All Implemented Interfaces:
Savable,Serializable,Cloneable
Mathematically, quaternions are an extension of complex numbers. In mathematics texts, W often appears first, but in JME it always comes last.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QuaternionAnother shared instance of the identity quaternion (0, 0, 0, 1).static final QuaternionShared instance of the identity quaternion (0, 0, 0, 1).protected floatThe real (W) component.protected floatThe first imaginary (X) component.protected floatThe 2nd imaginary (Y) component.protected floatThe 3rd imaginary (Z) component.static final QuaternionShared instance of the zero quaternion (0, 0, 0, 0). -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates an identity quaternion: all components zeroed exceptw, which is set to 1.Quaternion(float[] angles) Instantiates a quaternion from Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.Quaternion(float x, float y, float z, float w) Instantiates a quaternion with the specified components.Instantiates a copy of the argument.Quaternion(Quaternion q1, Quaternion q2, float interp) Instantiates a quaternion by interpolating between the specified quaternions. -
Method Summary
Modifier and TypeMethodDescriptionadd(Quaternion q) Adds the argument and returns the sum as a new instance.Adds the argument and returns the (modified) current instance.voidApplies the rotation represented by the argument to the current instance.clone()Creates a copy.floatdot(Quaternion q) Returns the dot product with the argument.booleanTests for exact equality with the argument, distinguishing -0 from 0.fromAngleAxis(float angle, Vector3f axis) Sets the quaternion from the specified rotation angle and axis of rotation.fromAngleNormalAxis(float angle, Vector3f axis) Sets the quaternion from the specified rotation angle and normalized axis of rotation.fromAngles(float[] angles) Sets the quaternion from the specified Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.fromAngles(float xAngle, float yAngle, float zAngle) Sets the quaternion from the specified Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.Sets the quaternion from the specified orthonormal basis.Sets the quaternion from the specified orthonormal basis.fromRotationMatrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) Sets the quaternion from a rotation matrix with the specified elements.fromRotationMatrix(Matrix3f matrix) Sets the quaternion from the specified rotation matrix.getRotationColumn(int i) Calculates one of the basis vectors of the rotation.getRotationColumn(int i, Vector3f store) Calculates one of the basis vectors of the rotation.floatgetW()Returns the W (real) component.floatgetX()Returns the X component.floatgetY()Returns the Y component.floatgetZ()Returns the Z component.inthashCode()Returns a hash code.inverse()Returns the multiplicative inverse.Inverts the quaternion and returns the (modified) current instance.booleanCompares with the identity quaternion, without distinguishing -0 from 0.booleanisSimilar(Quaternion other, float epsilon) Tests for approximate equality with the specified quaternion, using the specified tolerance.static booleanisValidQuaternion(Quaternion quaternion) Tests whether the argument is a valid quaternion, returning false if it's null or if any component is NaN or infinite.voidSets all components to zero exceptw, which is set to 1.Convenience method to set the quaternion based on a "look" (Z-axis) direction and an "up" (Y-axis) direction.mult(float scalar) Multiplies with the scalar argument and returns the product as a new instance.mult(Quaternion q) Multiplies by the argument and returns the product as a new instance.mult(Quaternion q, Quaternion storeResult) Multiplies by the specified quaternion and returns the product in a 3rd quaternion.Rotates the argument vector and returns the result as a new vector.Rotates a specified vector and returns the result in another vector.multLocal(float scalar) Multiplies by the scalar argument and returns the (modified) current instance.multLocal(float qx, float qy, float qz, float qw) Multiplies by a quaternion with the specified components and returns the (modified) current instance.Multiplies by the argument and returns the (modified) current instance.Rotates the argument vector.voidnegate()Deprecated.The naming of this method doesn't follow convention.Negates all 4 components and returns the (modified) current instance.voidnlerp(Quaternion q2, float blend) Interpolates quickly between the current instance andq2using nlerp, and stores the result in the current instance.floatnorm()Returns the norm, defined as the dot product of the quaternion with itself.Scales the quaternion to have norm=1 and returns the (modified) current instance.opposite()opposite(Quaternion store) Returns a rotation with the same axis and the angle increased by 180 degrees.Changes the quaternion to a rotation with the same axis and the angle increased by 180 degrees.voidread(JmeImporter importer) De-serializes from the specified importer, for example when loading from a J3O file.voidSets the quaternion from anObjectInputobject.set(float x, float y, float z, float w) Sets all 4 components to specified values.set(Quaternion q) Copies all 4 components from the argument.voidslerp(Quaternion q2, float changeAmount) Interpolates between the current instance andq2and stores the result in the current instance.slerp(Quaternion q1, Quaternion q2, float t) Interpolates between the specified quaternions and stores the result in the current instance.Subtracts the argument and returns difference as a new instance.Subtracts the argument and returns the (modified) current instance.floattoAngleAxis(Vector3f axisStore) Converts the quaternion to a rotation angle and axis of rotation, storing the axis in the argument (if it's non-null) and returning the angle.float[]toAngles(float[] angles) Converts to equivalent Tait-Bryan angles, to be applied in x-z-y intrinsic order or y-z'-x" extrinsic order, for instance byfromAngles(float[]).voidConverts the quaternion to a rotated coordinate system and stores the resulting axes in the argument.Converts to an equivalent rotation matrix.toRotationMatrix(Matrix3f result) Converts to an equivalent rotation matrix.toRotationMatrix(Matrix4f result) Sets the rotation component of the specified transform matrix.toString()Returns a string representation of the quaternion, which is unaffected.toTransformMatrix(Matrix4f store) Sets the rotation component of the specified transform matrix.voidwrite(JmeExporter e) Serializes to the specified exporter, for example when saving to a J3O file.voidWrites the quaternion to anObjectOutputobject.
-
Field Details
-
IDENTITY
Shared instance of the identity quaternion (0, 0, 0, 1). Do not modify!This is the usual representation for a null rotation.
-
DIRECTION_Z
Another shared instance of the identity quaternion (0, 0, 0, 1). Do not modify! -
ZERO
Shared instance of the zero quaternion (0, 0, 0, 0). Do not modify!The zero quaternion doesn't represent any valid rotation.
-
x
protected float xThe first imaginary (X) component. Not an angle! -
y
protected float yThe 2nd imaginary (Y) component. Not an angle! -
z
protected float zThe 3rd imaginary (Z) component. Not an angle! -
w
protected float wThe real (W) component. Not an angle!
-
-
Constructor Details
-
Quaternion
public Quaternion()Instantiates an identity quaternion: all components zeroed exceptw, which is set to 1. -
Quaternion
public Quaternion(float x, float y, float z, float w) Instantiates a quaternion with the specified components.- Parameters:
x- the desired X componenty- the desired Y componentz- the desired Z componentw- the desired W component
-
Quaternion
public Quaternion(float[] angles) Instantiates a quaternion from Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.- Parameters:
angles- an array of Tait-Bryan angles (in radians, exactly 3 elements, the X angle inangles[0], the Y angle inangles[1], and the Z angle inangles[2], not null, unaffected)
-
Quaternion
Instantiates a quaternion by interpolating between the specified quaternions.Uses
slerp(com.jme3.math.Quaternion, com.jme3.math.Quaternion, float), which is fast but inaccurate.- Parameters:
q1- the desired value when interp=0 (not null, unaffected)q2- the desired value when interp=1 (not null, may be modified)interp- the fractional change amount
-
Quaternion
Instantiates a copy of the argument.- Parameters:
q- the quaternion to copy (not null, unaffected)
-
-
Method Details
-
getX
public float getX()Returns the X component. The quaternion is unaffected.- Returns:
- the value of the
xcomponent
-
getY
public float getY()Returns the Y component. The quaternion is unaffected.- Returns:
- the value of the
ycomponent
-
getZ
public float getZ()Returns the Z component. The quaternion is unaffected.- Returns:
- the value of the
zcomponent
-
getW
public float getW()Returns the W (real) component. The quaternion is unaffected.- Returns:
- the value of the
wcomponent
-
set
Sets all 4 components to specified values.- Parameters:
x- the desired X componenty- the desired Y componentz- the desired Z componentw- the desired W component- Returns:
- the (modified) current instance (for chaining)
-
set
Copies all 4 components from the argument.- Parameters:
q- the quaternion to copy (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
loadIdentity
public void loadIdentity()Sets all components to zero exceptw, which is set to 1. -
isIdentity
public boolean isIdentity()Compares with the identity quaternion, without distinguishing -0 from 0. The current instance is unaffected.- Returns:
- true if the current quaternion equals the identity, otherwise false
-
fromAngles
Sets the quaternion from the specified Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.- Parameters:
angles- an array of Tait-Bryan angles (in radians, exactly 3 elements, the X angle inangles[0], the Y angle inangles[1], and the Z angle inangles[2], not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
- Throws:
IllegalArgumentException- ifangles.length != 3
-
fromAngles
Sets the quaternion from the specified Tait-Bryan angles, applying the rotations in x-z-y extrinsic order or y-z'-x" intrinsic order.- Parameters:
xAngle- the X angle (in radians)yAngle- the Y angle (in radians)zAngle- the Z angle (in radians)- Returns:
- the (modified) current instance (for chaining)
- See Also:
-
toAngles
public float[] toAngles(float[] angles) Converts to equivalent Tait-Bryan angles, to be applied in x-z-y intrinsic order or y-z'-x" extrinsic order, for instance byfromAngles(float[]). The current instance is unaffected.- Parameters:
angles- storage for the result, or null for a new float[3]- Returns:
- an array of 3 angles (in radians, either
anglesor a new float[3], the X angle in angles[0], the Y angle in angles[1], and the Z angle in angles[2]) - Throws:
IllegalArgumentException- ifangles.length != 3- See Also:
-
fromRotationMatrix
Sets the quaternion from the specified rotation matrix.Does not verify that the argument is a valid rotation matrix. Positive scaling is compensated for, but not reflection or shear.
- Parameters:
matrix- the input matrix (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
fromRotationMatrix
public Quaternion fromRotationMatrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) Sets the quaternion from a rotation matrix with the specified elements.Does not verify that the arguments form a valid rotation matrix. Positive scaling is compensated for, but not reflection or shear.
- Parameters:
m00- the matrix element in row 0, column 0m01- the matrix element in row 0, column 1m02- the matrix element in row 0, column 2m10- the matrix element in row 1, column 0m11- the matrix element in row 1, column 1m12- the matrix element in row 1, column 2m20- the matrix element in row 2, column 0m21- the matrix element in row 2, column 1m22- the matrix element in row 2, column 2- Returns:
- the (modified) current instance (for chaining)
-
toRotationMatrix
Converts to an equivalent rotation matrix. The current instance is unaffected.Note: the result is created from a normalized version of the current instance.
- Returns:
- a new 3x3 rotation matrix
-
toRotationMatrix
Converts to an equivalent rotation matrix. The current instance is unaffected.Note: the result is created from a normalized version of the current instance.
- Parameters:
result- storage for the result (not null)- Returns:
result, configured as a 3x3 rotation matrix
-
toTransformMatrix
Sets the rotation component of the specified transform matrix. The current instance is unaffected.Note: preserves the translation component of
storebut not its scaling component.Note: the result is created from a normalized version of the current instance.
- Parameters:
store- storage for the result (not null)- Returns:
store, with 9 of its 16 elements modified
-
toRotationMatrix
Sets the rotation component of the specified transform matrix. The current instance is unaffected.Note: preserves the translation and scaling components of
resultunlessresultincludes reflection.Note: the result is created from a normalized version of the current instance.
- Parameters:
result- storage for the result (not null)- Returns:
result, with 9 of its 16 elements modified
-
getRotationColumn
Calculates one of the basis vectors of the rotation. The current instance is unaffected.Note: the result is created from a normalized version of the current instance.
- Parameters:
i- which basis vector to retrieve (≥0, <3, 0→X-axis, 1→Y-axis, 2→Z-axis)- Returns:
- the basis vector (a new Vector3f)
-
getRotationColumn
Calculates one of the basis vectors of the rotation. The current instance is unaffected.Note: the result is created from a normalized version of the current instance.
- Parameters:
i- which basis vector to retrieve (≥0, <3, 0→X-axis, 1→Y-axis, 2→Z-axis)store- storage for the result, or null for a new Vector3f- Returns:
- the basis vector (either
storeor a new Vector3f) - Throws:
IllegalArgumentException- if index is not 0, 1, or 2
-
fromAngleAxis
Sets the quaternion from the specified rotation angle and axis of rotation. This method creates garbage, so usefromAngleNormalAxis(float, com.jme3.math.Vector3f)if the axis is known to be normalized.- Parameters:
angle- the desired rotation angle (in radians)axis- the desired axis of rotation (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
fromAngleNormalAxis
Sets the quaternion from the specified rotation angle and normalized axis of rotation. If the axis might not be normalized, usefromAngleAxis(float, com.jme3.math.Vector3f)instead.- Parameters:
angle- the desired rotation angle (in radians)axis- the desired axis of rotation (not null, length=1, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
toAngleAxis
Converts the quaternion to a rotation angle and axis of rotation, storing the axis in the argument (if it's non-null) and returning the angle.If the quaternion has
x*x + y*y + z*z == 0, then (1,0,0) is stored and 0 is returned. (This might happen if the rotation angle is very close to 0.)Otherwise, the quaternion is assumed to be normalized (norm=1). No error checking is performed; the caller must ensure that the quaternion is normalized.
In all cases, the current instance is unaffected.
- Parameters:
axisStore- storage for the axis (modified if not null)- Returns:
- the rotation angle (in radians)
-
slerp
Interpolates between the specified quaternions and stores the result in the current instance.- Parameters:
q1- the desired value when interp=0 (not null, unaffected)q2- the desired value when interp=1 (not null, may be modified)t- the fractional change amount- Returns:
- the (modified) current instance (for chaining)
-
slerp
Interpolates between the current instance andq2and stores the result in the current instance.This method is often more accurate than
nlerp(com.jme3.math.Quaternion, float), but slower.- Parameters:
q2- the desired value when changeAmnt=1 (not null, may be modified)changeAmount- the fractional change amount
-
nlerp
Interpolates quickly between the current instance andq2using nlerp, and stores the result in the current instance.This method is often faster than
slerp(com.jme3.math.Quaternion, float), but less accurate.- Parameters:
q2- the desired value when blend=1 (not null, unaffected)blend- the fractional change amount
-
add
Adds the argument and returns the sum as a new instance. The current instance is unaffected.Seldom used. To combine rotations, use
mult(com.jme3.math.Quaternion)instead of this method.- Parameters:
q- the quaternion to add (not null, unaffected)- Returns:
- a new Quaternion
-
addLocal
Adds the argument and returns the (modified) current instance.Seldom used. To combine rotations, use
multLocal(com.jme3.math.Quaternion)ormult(com.jme3.math.Quaternion, com.jme3.math.Quaternion)instead of this method.- Parameters:
q- the quaternion to add (not null, unaffected unless it'sthis)- Returns:
- the (modified) current instance (for chaining)
-
subtract
Subtracts the argument and returns difference as a new instance. The current instance is unaffected.- Parameters:
q- the quaternion to subtract (not null, unaffected)- Returns:
- a new Quaternion
-
subtractLocal
Subtracts the argument and returns the (modified) current instance.To quantify the similarity of 2 normalized quaternions, use
dot(com.jme3.math.Quaternion).- Parameters:
q- the quaternion to subtract (not null, unaffected unless it'sthis)- Returns:
- the (modified) current instance
-
mult
Multiplies by the argument and returns the product as a new instance. The current instance is unaffected.This method is used to combine rotations. Note that quaternion multiplication is noncommutative, so generally q * p != p * q.
- Parameters:
q- the right factor (not null, unaffected)- Returns:
this * q(a new Quaternion)
-
mult
Multiplies by the specified quaternion and returns the product in a 3rd quaternion. The current instance is unaffected, unless it'sstoreResult.This method is used to combine rotations. Note that quaternion multiplication is noncommutative, so generally q * p != p * q.
It is safe for
qandstoreResultto be the same object. However, ifthisandstoreResultare the same object, the result is undefined.- Parameters:
q- the right factor (not null, unaffected unless it'sstoreResult)storeResult- storage for the product, or null for a new Quaternion- Returns:
this * q(eitherstoreResultor a new Quaternion)
-
apply
Applies the rotation represented by the argument to the current instance.Does not verify that
matrixis a valid rotation matrix. Positive scaling is compensated for, but not reflection or shear.- Parameters:
matrix- the rotation matrix to apply (not null, unaffected)
-
fromAxes
Sets the quaternion from the specified orthonormal basis.The 3 basis vectors describe the axes of a rotated coordinate system. They are assumed to be normalized, mutually orthogonal, and in right-hand order. No error checking is performed; the caller must ensure that the specified vectors represent a right-handed coordinate system.
- Parameters:
axis- the array of desired basis vectors (not null, array length=3, each vector having length=1, unaffected)- Returns:
- the (modified) current instance (for chaining)
- Throws:
IllegalArgumentException- ifaxis.length != 3
-
fromAxes
Sets the quaternion from the specified orthonormal basis.The 3 basis vectors describe the axes of a rotated coordinate system. They are assumed to be normalized, mutually orthogonal, and in right-hand order. No error checking is performed; the caller must ensure that the specified vectors represent a right-handed coordinate system.
- Parameters:
xAxis- the X axis of the desired coordinate system (not null, length=1, unaffected)yAxis- the Y axis of the desired coordinate system (not null, length=1, unaffected)zAxis- the Z axis of the desired coordinate system (not null, length=1, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
toAxes
Converts the quaternion to a rotated coordinate system and stores the resulting axes in the argument. The current instance is unaffected.The resulting vectors form the basis of a rotated coordinate system. They will be normalized, mutually orthogonal, and in right-hand order.
- Parameters:
axes- storage for the results (not null, length=3, each element non-null, elements modified)- Throws:
IllegalArgumentException- ifaxes.length != 3
-
mult
Rotates the argument vector and returns the result as a new vector. The current instance is unaffected.The quaternion is assumed to be normalized (norm=1). No error checking is performed; the caller must ensure that the norm is approximately equal to 1.
Despite the name, the result differs from the mathematical definition of vector-quaternion multiplication.
- Parameters:
v- the vector to rotate (not null, unaffected)- Returns:
- a new Vector3f
-
multLocal
Rotates the argument vector. Despite the name, the current instance is unaffected.The quaternion is assumed to be normalized (norm=1). No error checking is performed; the caller must ensure that the norm is approximately equal to 1.
Despite the name, the result differs from the mathematical definition of vector-quaternion multiplication.
- Parameters:
v- the vector to rotate (not null)- Returns:
- the (modified) vector
v
-
multLocal
Multiplies by the argument and returns the (modified) current instance.This method is used to combine rotations. Note that quaternion multiplication is noncommutative, so generally q * p != p * q.
- Parameters:
q- the right factor (not null, unaffected unless it'sthis)- Returns:
- the (modified) current instance (for chaining)
-
multLocal
Multiplies by a quaternion with the specified components and returns the (modified) current instance.This method is used to combine rotations. Note that quaternion multiplication is noncommutative, so generally q * p != p * q.
- Parameters:
qx- the X component of the right factorqy- the Y component of the right factorqz- the Z component of the right factorqw- the W component of the right factor- Returns:
- the (modified) current instance (for chaining)
-
mult
Rotates a specified vector and returns the result in another vector. The current instance is unaffected.The quaternion is assumed to be normalized (norm=1). No error checking is performed; the caller must ensure that the norm is approximately equal to 1.
It is safe for
vandstoreto be the same object.Despite the name, the result differs from the mathematical definition of vector-quaternion multiplication.
- Parameters:
v- the vector to rotate (not null, unaffected unless it'sstore)store- storage for the result, or null for a new Vector3f- Returns:
- the rotated vector (either
storeor a new Vector3f)
-
mult
Multiplies with the scalar argument and returns the product as a new instance. The current instance is unaffected.- Parameters:
scalar- the scaling factor- Returns:
- a new Quaternion
-
multLocal
Multiplies by the scalar argument and returns the (modified) current instance.- Parameters:
scalar- the scaling factor- Returns:
- the (modified) current instance (for chaining)
-
dot
Returns the dot product with the argument. The current instance is unaffected.This method can be used to quantify the similarity of 2 normalized quaternions.
- Parameters:
q- the quaternion to multiply (not null, unaffected)- Returns:
- the dot product
-
norm
public float norm()Returns the norm, defined as the dot product of the quaternion with itself. The current instance is unaffected.- Returns:
- the sum of the squared components (not negative)
-
normalizeLocal
Scales the quaternion to have norm=1 and returns the (modified) current instance. For a quaternion with norm=0, the result is undefined.- Returns:
- the (modified) current instance (for chaining)
-
inverse
Returns the multiplicative inverse. For a quaternion with norm=0, null is returned. Either way, the current instance is unaffected.- Returns:
- a new Quaternion or null
-
inverseLocal
Inverts the quaternion and returns the (modified) current instance. For a quaternion with norm=0, the current instance is unchanged.- Returns:
- the current instance (for chaining)
-
negate
Deprecated.The naming of this method doesn't follow convention. Please usenegateLocal()instead.Negates all 4 components. -
negateLocal
Negates all 4 components and returns the (modified) current instance.- Returns:
- the (modified) current instance (for chaining)
-
toString
Returns a string representation of the quaternion, which is unaffected. For example, the identity quaternion is represented by:(0.0, 0.0, 0.0, 1.0)
-
equals
Tests for exact equality with the argument, distinguishing -0 from 0. Ifois null, false is returned. Either way, the current instance is unaffected. -
isSimilar
Tests for approximate equality with the specified quaternion, using the specified tolerance. The current instance is unaffected.To quantify the similarity of 2 normalized quaternions, use
dot(com.jme3.math.Quaternion).- Parameters:
other- the quaternion to compare (not null, unaffected)epsilon- the tolerance for each component- Returns:
- true if all 4 components are within tolerance, otherwise false
-
hashCode
public int hashCode()Returns a hash code. If two quaternions have identical values, they will have the same hash code. The current instance is unaffected. -
readExternal
Sets the quaternion from anObjectInputobject.Used with serialization. Should not be invoked directly by application code.
- Parameters:
in- the object to read from (not null)- Throws:
IOException- if the ObjectInput cannot read a float- See Also:
-
writeExternal
Writes the quaternion to anObjectOutputobject.Used with serialization. Should not be invoked directly by application code.
- Parameters:
out- the object to write to (not null)- Throws:
IOException- if the ObjectOutput cannot write a float- See Also:
-
lookAt
Convenience method to set the quaternion based on a "look" (Z-axis) direction and an "up" (Y-axis) direction.If either vector has length=0, the result is undefined.
If the vectors are parallel, the result is undefined.
- Parameters:
direction- the desired Z-axis direction (in local coordinates, not null, length>0, unaffected)up- the desired Y-axis direction (in local coordinates, not null, length>0, unaffected, typically (0,1,0) )- Returns:
- the (modified) current instance (for chaining)
-
write
Serializes to the specified exporter, for example when saving to a J3O file. The current instance is unaffected.- Specified by:
writein interfaceSavable- Parameters:
e- the exporter to use (not null)- Throws:
IOException- from the exporter
-
read
De-serializes from the specified importer, for example when loading from a J3O file.- Specified by:
readin interfaceSavable- Parameters:
importer- the importer to use (not null)- Throws:
IOException- from the importer
-
opposite
- Returns:
- A new quaternion that describes a rotation that would point you in the exact opposite direction of this Quaternion.
-
opposite
Returns a rotation with the same axis and the angle increased by 180 degrees. If the quaternion isn't normalized, or if the rotation angle is very small, the result is undefined.The current instance is unaffected, unless
storeisthis.- Parameters:
store- storage for the result, or null for a new Quaternion- Returns:
- either
storeor a new Quaternion
-
oppositeLocal
Changes the quaternion to a rotation with the same axis and the angle increased by 180 degrees. If the quaternion isn't normalized, or if the rotation angle is very small, the result is undefined.- Returns:
- the (modified) current instance
-
clone
Creates a copy. The current instance is unaffected. -
isValidQuaternion
Tests whether the argument is a valid quaternion, returning false if it's null or if any component is NaN or infinite.- Parameters:
quaternion- the quaternion to test (unaffected)- Returns:
- true if non-null and finite, otherwise false
-