public final class Quatd
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Methods with names ending in "Local" modify the current instance. They are used to avoid creating temporary objects.
Mathematically, quaternions are an extension of complex numbers. In mathematics texts, W often appears first, but here the conventional order is (X, Y, Z, W).
| Modifier and Type | Field and Description |
|---|---|
double |
w
The real (W) component.
|
double |
x
The first imaginary (X) component.
|
double |
y
The 2nd imaginary (Y) component.
|
double |
z
The 3rd imaginary (Z) component.
|
| Constructor and Description |
|---|
Quatd()
Instantiates an identity quaternion: all components zeroed except
w, which is set to 1. |
Quatd(double x,
double y,
double z,
double w)
Instantiates a quaternion with the specified components.
|
Quatd(Quatd quat)
Instantiates a copy of the argument.
|
Quatd(com.jme3.math.Quaternion quat)
Instantiates based on the specified (single-precision) Quaternion.
|
| Modifier and Type | Method and Description |
|---|---|
Quatd |
add(Quatd q)
Adds the argument and returns the sum as a new instance.
|
Quatd |
addLocal(Quatd q)
Adds the argument and returns the (modified) current instance.
|
Quatd |
addScaledVectorLocal(Vec3d v,
double scale) |
Quatd |
clone()
Creates a copy.
|
boolean |
equals(java.lang.Object o)
Tests for exact equality with the argument, distinguishing -0 from 0.
|
Quatd |
fromAngles(double[] angles)
Builds a Quaternion from the Euler rotation angles (x,y,z) aka
(pitch, yaw, roll).
|
Quatd |
fromAngles(double xAngle,
double yAngle,
double zAngle)
Builds a Quaternion from the Euler rotation angles (x,y,z) aka
(pitch, yaw, roll).
|
double |
get(int i)
Returns the indexed component.
|
int |
hashCode()
Returns a hash code.
|
Quatd |
inverse()
Returns the multiplicative inverse.
|
boolean |
isRotationIdentity()
Tests for an identity rotation.
|
boolean |
isSimilar(Quatd other,
double epsilon)
Returns true if this Quatd is similar to the specified Quatd within
some value of epsilon.
|
boolean |
isZero()
Tests for a zero value.
|
double |
lengthSq()
Returns the squared length.
|
Quatd |
mult(Quatd q)
Takes the Hamilton product of the current instance times the argument to
yield a new Quatd.
|
Quatd |
mult(Quatd q,
Quatd result)
Takes the Hamilton product of the current instance times the first
argument and returns the product in the 2nd argument.
|
Vec3d |
mult(Vec3d v)
Rotates the argument vector to produce a new vector.
|
Vec3d |
mult(Vec3d v,
Vec3d result)
Rotates a specified vector and return the result in another vector.
|
Quatd |
multLocal(Quatd q)
Takes the Hamilton product of the current instance times the argument,
in place.
|
Quatd |
normalizeLocal()
Normalizes the current instance in place.
|
Quatd |
set(double x,
double y,
double z,
double w)
Sets all 4 components to the specified values.
|
Quatd |
set(int i,
double d)
Alters the indexed component.
|
Quatd |
set(Quatd q)
Copies all 4 components from the argument.
|
Quatd |
set(com.jme3.math.Quaternion quat)
Copies all 4 components of the specified (single-precision) Quaternion to
the current instance.
|
Quatd |
slerpLocal(Quatd start,
Quatd end,
double mix)
Sets this Quatd's value to the linear interpolation of start
and end using the mix value as the amount to interpolate.
|
Quatd |
subtract(Quatd q)
Subtracts the argument and returns the difference as a new instance.
|
Quatd |
subtractLocal(Quatd q)
Subtracts the argument and returns the (modified) current instance.
|
double[] |
toAngles(double[] angles)
Returns this quaternion converted to Euler rotation angles (yaw,roll,pitch).
|
com.jme3.math.Quaternion |
toQuaternion()
Creates a (single-precision) Quaternion that approximates the current
instance.
|
Matrix3d |
toRotationMatrix()
Converts the quaternion to an equivalent rotation matrix.
|
java.lang.String |
toString()
Returns a string representation of the quaternion, which is unaffected.
|
public double x
public double y
public double z
public double w
public Quatd()
w, which is set to 1.public Quatd(double x,
double y,
double z,
double w)
x - the desired X componenty - the desired Y componentz - the desired Z componentw - the desired W componentpublic Quatd(Quatd quat)
quat - the quaternion to copy (not null, unaffected)public Quatd(com.jme3.math.Quaternion quat)
quat - the input Quaternion (not null, unaffected)public final Quatd clone()
clone in class java.lang.Objectpublic com.jme3.math.Quaternion toQuaternion()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
o is null, false is returned. Either way, the current instance is
unaffected.equals in class java.lang.Objecto - the object to compare (may be null, unaffected)this and o have identical values,
otherwise falsepublic boolean isSimilar(Quatd other, double epsilon)
other - the Quatd to compare (may be null, unaffected)epsilon - the tolerance for comparisonpublic boolean isRotationIdentity()
public boolean isZero()
public final Quatd set(double x, double y, double z, double w)
x - the desired X componenty - the desired Y componentz - the desired Z componentw - the desired W componentpublic final Quatd set(Quatd q)
q - the quaternion to copy (not null, unaffected)public final Quatd set(com.jme3.math.Quaternion quat)
quat - the input Quaternion (not null, unaffected)public double get(int i)
i - 0, 1, 2, or 3java.lang.IndexOutOfBoundsException - if i is not 0, 1, 2, or 3public Quatd set(int i, double d)
i - which component to set: 0 → the X component, 1 →
the Y component, 2 → the Z component, 3 → the W componentd - the desired component valuejava.lang.IllegalArgumentException - if i is not 0, 1, 2, or 3public final Quatd add(Quatd q)
q - the Quatd to add (not null, unaffected)public final Quatd addLocal(Quatd q)
It IS safe for q and this to be the same object.
q - the Quatd to add (not null, unaffected unless it's this)public final Quatd subtract(Quatd q)
q - the Quatd to subtract (not null, unaffected)public final Quatd subtractLocal(Quatd q)
It IS safe for q and this to be the same object.
q - the Quatd to subtract (not null, unaffected unless it's
this)public final Quatd mult(Quatd q)
It is safe for q and this to be the same object.
This method is used to combine rotations. Note that the Hamilton product is noncommutative, so generally q * p != p * q.
q - the right factor (not null, unaffected)this * q (a new instance)public final Quatd mult(Quatd q, Quatd result)
result.
This method is used to combine rotations. Note that the Hamilton product is noncommutative, so generally q * p != p * q.
It is safe for any or all of q, result, and this
to be the same object.
q - the right factor (not null, unaffected unless it's
result)result - storage for the product, or null for a new Quatdthis * q (either result or a new Quatd)public final Quatd multLocal(Quatd q)
This method is used to combine rotations. Note that the Hamilton product is noncommutative, so generally q * p != p * q.
It IS safe for q and this to be the same object.
q - the right factor (not null, unaffected unless it's this)public Vec3d mult(Vec3d v)
v - the input vector (not null, unaffected)public Vec3d mult(Vec3d v, Vec3d result)
It IS safe for v and result to be the same object.
v - the vector to rotate (not null, unaffected unless it's
result)result - storage for the result (not null)resultpublic final double lengthSq()
public final Quatd normalizeLocal()
public Matrix3d toRotationMatrix()
Note: the result is created from a normalized version of the current instance.
public Quatd inverse()
null is returned. Either way, the current instance is unaffected.public Quatd fromAngles(double[] angles)
angles - the rotation angles for each axis (in radians, not null,
length ≥3)public Quatd fromAngles(double xAngle, double yAngle, double zAngle)
xAngle - the desired rotation about the +X axis (in radians)yAngle - the desired rotation about the +Y axis (in radians)zAngle - the desired rotation about the +Z axis (in radians)public double[] toAngles(double[] angles)
angles - the double[] in which the angles should be stored, or null if
you want a new double[] to be createdpublic Quatd slerpLocal(Quatd start, Quatd end, double mix)
start - the desired value when mix is zero (not null,
unaffected unless it's this)end - the desired value when mix is one (not null,
unaffected unless it's this)mix - typically between 0 and 1 inclusivepublic java.lang.String toString()
Quatd[0.0, 0.0, 0.0, 1.0]
toString in class java.lang.Object