public class Quaternion
extends java.lang.Object
Quaternion represented by four coordinates: X, Y, Z, W
Quaternion q = new Quaternion();
q.setFromAxisAngle( new Vector3( 0, 1, 0 ), Math.PI / 2 );
Vector3 v = new Vector3( 1, 0, 0 );
q.multiplyVector3( v );
Modifier and Type | Class and Description |
---|---|
static interface |
Quaternion.QuaternionChangeHandler |
Modifier and Type | Field and Description |
---|---|
double |
w
The W coordinate.
|
double |
x
The X coordinate.
|
double |
y
The Y coordinate.
|
double |
z
The Z coordinate.
|
Constructor and Description |
---|
Quaternion()
Default constructor will make Quaternion (0.0, 0.0, 0.0, 1.0)
|
Quaternion(double x,
double y,
double z)
Constructs and initializes a Quaternion from the specified X, Y, Z coordinates.
|
Quaternion(double x,
double y,
double z,
double w)
Constructs and initializes a Quaternion from the specified X, Y, Z, W
coordinates.
|
Modifier and Type | Method and Description |
---|---|
Quaternion |
clone()
Clone the current Quaternion
quaternion.clone() !
|
Quaternion |
conjugate() |
Quaternion |
copy(Quaternion c1)
Copy values from input Quaternion to the values of current Quaternion.
|
double |
dot(Quaternion v) |
boolean |
equals(Quaternion quaternion) |
double |
getW()
get W coordinate from the Quaternion
|
double |
getX()
get X coordinate from the Quaternion
|
double |
getY()
get Y coordinate from the Quaternion
|
double |
getZ()
get Z coordinate from the Quaternion
|
Quaternion |
inverse()
Negates the value of this Quaternion in place.
|
double |
length() |
double |
lengthSq() |
Quaternion |
multiply(Quaternion b)
Sets the value of this Quaternion to the vector multiplication of itself and
Quaternion b.
|
Quaternion |
multiply(Quaternion a,
Quaternion b)
Sets the value of this Quaternion to the vector multiplication of Quaternion a and
Quaternion v2.
|
Vector3 |
multiplyVector3(Vector3 vector)
Sets the value of the input vector to the vector multiplication of input vector and
the current Quaternion.
|
Quaternion |
normalize()
Normalize the current Quaternion
|
Quaternion |
set(double x,
double y,
double z,
double w) |
Quaternion |
setFromAxisAngle(Vector3 axis,
double angle)
|
Quaternion |
setFromEuler(Euler euler) |
Quaternion |
setFromEuler(Euler euler,
boolean update) |
Quaternion |
setFromRotationMatrix(Matrix4 m)
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
Quaternion |
setFromUnitVectors(Vector3 vFrom,
Vector3 vTo)
http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final
assumes direction vectors vFrom and vTo are normalized
|
void |
setHandler(Quaternion.QuaternionChangeHandler handler) |
Quaternion |
slerp(Quaternion qb,
double t)
Quaternion Interpolation
Based on http://www.euclideanspace.com
|
static Quaternion |
slerp(Quaternion qa,
Quaternion qb,
Quaternion qm,
double t) |
java.lang.String |
toString() |
public double x
public double y
public double z
public double w
public Quaternion()
public Quaternion(double x, double y, double z, double w)
x
- the X coordinatey
- the Y coordinatez
- the Z coordinatew
- the W coordinatepublic Quaternion(double x, double y, double z)
x
- the x coordinatey
- the y coordinatez
- the z coordinatepublic void setHandler(Quaternion.QuaternionChangeHandler handler)
public double getX()
public double getY()
public double getZ()
public double getW()
public Quaternion set(double x, double y, double z, double w)
public Quaternion copy(Quaternion c1)
c1
- the input Quaternionpublic Quaternion setFromEuler(Euler euler)
public Quaternion setFromEuler(Euler euler, boolean update)
public Quaternion setFromAxisAngle(Vector3 axis, double angle)
axis
- the axis have to be normalizedangle
- the anglepublic Quaternion setFromRotationMatrix(Matrix4 m)
m
- public Quaternion setFromUnitVectors(Vector3 vFrom, Vector3 vTo)
vFrom
- vTo
- public Quaternion inverse()
public Quaternion conjugate()
public double dot(Quaternion v)
public double lengthSq()
public double length()
public Quaternion normalize()
public Quaternion multiply(Quaternion a, Quaternion b)
a
- the first Quaternionb
- the second Quaternionpublic Quaternion multiply(Quaternion b)
b
- the other Quaternionpublic Vector3 multiplyVector3(Vector3 vector)
vector
- the input vectorpublic Quaternion slerp(Quaternion qb, double t)
qb
- the quaternion a (first quaternion to be interpolated between)t
- a scalar between 0.0 (at qa) and 1.0 (at qb)public static Quaternion slerp(Quaternion qa, Quaternion qb, Quaternion qm, double t)
public boolean equals(Quaternion quaternion)
public Quaternion clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object