public class Quaternion extends java.lang.Object implements IInterpolate<Quaternion>, ICopy<Quaternion>, IQuantity
Provided Quaternion operations include basic mathematic operations as well as a method for interpolation.
Quaternions actually describe 4 separate rotations - 3 dimensions of rotation about a coordinate reference frame, and then a fourth rotation of the coodinate reference frame to another reference frame.
At their core, Quaternions are comprised of W, X, Y and Z components, which in the case of the Unit Quaternion are expressed in units of Radians which have a range from -2 to 2.
From a number theory perspecive, a quaternion is a complex number. A quaternion is a formal sum of a real number and real multiples of the symbols i, j, and k. For example,
A Unit Quaternion can express not only rotations, but also the gravity vector. Therefore, the Quaternion class provides methods for deriving the gravity vector as well as the more commonly-used Yaw, Pitch and Roll angles (also known as Tait/Bryan angles).
Constructor and Description |
---|
Quaternion()
Constructs a Quaternion instance, using default values for a Unit
Quaternion.
|
Quaternion(float w,
float x,
float y,
float z)
Constructs a Quaternion instance, using the provides w, x, y and z
valuese.
|
Quaternion(Quaternion src)
Constructs a Quaternion instance, using values from another Quaternion
instance.
|
Modifier and Type | Method and Description |
---|---|
void |
conjugate()
Modifies the Quaternion to be its complex conjugate.
|
void |
copy(Quaternion t) |
static void |
difference(Quaternion qa,
Quaternion qb,
Quaternion q_diff)
Divides two quaternions.
|
void |
divide(float s)
Modifies a quaternion, scaling it by the provided parameter.
|
float |
dotProduct(Quaternion q1,
Quaternion q2) |
boolean |
getContainedQuantities(java.util.ArrayList<IQuantity> quantities) |
boolean |
getContainedQuantityNames(java.util.ArrayList<java.lang.String> quantity_names) |
void |
getPitch(Scalar pitch)
Extracts the pitch angle value from the Quaternion.
|
boolean |
getPrintableString(java.lang.StringBuilder printable_string) |
void |
getRoll(Scalar roll)
Extracts the roll angle value from the Quaternion.
|
static Unit.IUnit[] |
getUnits() |
float |
getW()
Accessor for the Quaternion's W component value.
|
float |
getX()
Accessor for the Quaternion's X component value.
|
float |
getY()
Accessor for the Quaternion's Y component value.
|
void |
getYawRadians(Scalar yaw)
Extracts the yaw angle value from the Quaternion.
|
float |
getZ()
Accessor for the Quaternion's Z component value.
|
Quaternion |
instantiate_copy() |
void |
interpolate(Quaternion to,
double time_ratio,
Quaternion out) |
void |
inverse()
Modifies the Quaternion to be its inverse (reciprocal).
|
void |
multiply(Quaternion q)
Modifies this quaternion (the multiplicand) to be the product of
multiplication by a multiplier Quaternion.
|
void |
set(float w,
float x,
float y,
float z)
Modifies the Quaternion by setting the component W, X, Y and Z value.
|
void |
set(Quaternion src)
Modifes the Quaternion to be equal to the provided Quaternion.
|
static void |
slerp(Quaternion qa,
Quaternion qb,
double t,
Quaternion out)
Estimates an intermediate Quaternion given Quaternions representing each
end of the path, and an interpolation ratio from 0.0 t0 1.0.
|
public Quaternion()
public Quaternion(Quaternion src)
src
- - the Quaternion instance used to initialize this Quaternion.public Quaternion(float w, float x, float y, float z)
w
- - the Quaternion W component value.x
- - the Quaternion X component value.y
- - the Quaternion Y component value.z
- - the Quaternion Z component value.public void set(float w, float x, float y, float z)
w
- - the Quaternion W component value.x
- - the Quaternion X component value.y
- - the Quaternion Y component value.z
- - the Quaternion Z component value.public void set(Quaternion src)
src
- - the Quaternion instance used to initialize this Quaternion.public void getYawRadians(Scalar yaw)
public void getPitch(Scalar pitch)
public void getRoll(Scalar roll)
public static void slerp(Quaternion qa, Quaternion qb, double t, Quaternion out)
public void conjugate()
public void inverse()
public void multiply(Quaternion q)
q
- - the multiplier quaternion.public void divide(float s)
s
- - the value by which to divide each Quaternion component
value.public float dotProduct(Quaternion q1, Quaternion q2)
public static void difference(Quaternion qa, Quaternion qb, Quaternion q_diff)
qa
- - the dividend Quaternionqb
- - the divisor Quaternionq_diff
- - the resulting quotient Quaternion representing the
difference in rotationpublic float getW()
public float getX()
public float getY()
public float getZ()
public void interpolate(Quaternion to, double time_ratio, Quaternion out)
interpolate
in interface IInterpolate<Quaternion>
public void copy(Quaternion t)
copy
in interface ICopy<Quaternion>
public Quaternion instantiate_copy()
instantiate_copy
in interface ICopy<Quaternion>
public static Unit.IUnit[] getUnits()
public boolean getPrintableString(java.lang.StringBuilder printable_string)
getPrintableString
in interface IQuantity
public boolean getContainedQuantities(java.util.ArrayList<IQuantity> quantities)
getContainedQuantities
in interface IQuantity
public boolean getContainedQuantityNames(java.util.ArrayList<java.lang.String> quantity_names)
getContainedQuantityNames
in interface IQuantity