public class Quaternion
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
DEGS_TO_RADS |
static float |
GS_EPSILON |
static Quaternion |
IDENTITY |
static double |
RADS_TO_DEGS |
static Quaternion |
ZERO |
Constructor and Description |
---|
Quaternion()
Constructs a new Quaternion with default values: w=1, xyz=0.
|
Quaternion(float[] xyzw)
Constructs a new Quaternion from the given component values
(with w last).
|
Quaternion(float roll,
float pitch,
float yaw)
Constructs a quaternion from the given "Euler" angles.
|
Quaternion(float ww,
float xx,
float yy,
float zz)
Constructs a new Quaternion from the given component values.
|
Quaternion(JAInputStream jins)
Constructs a new Quaternion by reading the values x,y,z,w
(in that order -- NB w comes last!) from the given input stream.
|
Quaternion(Quaternion q)
Constructs a copy of the given quaternion.
|
Modifier and Type | Method and Description |
---|---|
Quaternion |
add(Quaternion q)
Returns a new Quaternion representing this + q.
|
float[] |
asFloats()
Returns a copy of this quaternion as a new array of floats.
|
Quaternion |
exp()
Return a new Quaternion representing the exponential of this one.
|
void |
extractRotX(Quaternion qx)
Decomposes this quaternion into qx.qyz, where qx and qyz
represent rotations about, respectively, the x-axis and
some axis in the yz-plane, setting the given qx to be the
first of the two factors.
|
void |
fromAngleAxis(float angle,
float axisX,
float axisY,
float axisZ)
Sets this Quaternion to represent a rotation by the given
angle about the axis with the given components -- where the
axis length should be 1.
|
void |
fromAxisRotations(float roll,
float pitch,
float yaw)
Set this Quaternion from the given "Euler" angle values (in
degrees), that is, sequence of rotations about the axes.
|
float |
innerProd(Quaternion q)
Returns the inner product of this Quaternion with the given one.
|
Quaternion |
inverse()
Returns a new Quaternion containing the multiplicative inverse
of this one.
|
Quaternion |
inverseUnit()
Returns a new Quaternion containing the multiplicative inverse
of this one, assuming this one has unit length.
|
void |
invertUnit()
Inverts this Quaternion, assuming it has unit length.
|
float |
length()
Returns the length of this quaternion
|
Quaternion |
log()
Return a new Quaternion representing the logarithm of this one.
|
Quaternion |
negate()
Returns a new Quaternion representing the negation of this one.
|
void |
negateEq()
Negates this quaternion.
|
void |
negateXEq()
Negates the x component of this quaternion.
|
void |
normalize()
Normalizes this quaternion -- i.e.
|
void |
postDivideUnitEq(Quaternion q) |
Quaternion |
postMultiply(Quaternion q)
Returns a new Quaternion representing this * q.
|
void |
postMultiplyEq(Quaternion q)
Post-multiply this Quaternion by the given one,
that is, this := this * q -- using the full quaternion product:
* =
|
void |
preMultiplyEq(Quaternion q)
Pre-multiply this Quaternion by the given one,
that is, this := q * this (full quaternion product, as defined
for postMultiplyEq() above).
|
void |
save(JAOutputStream jouts)
Writes this quaternion to the given stream.
|
Quaternion |
scalarMultiply(float f)
Returns a new Quaternion representing this * f (scalar f).
|
void |
scalarMultiplyEq(float f)
Multiplies this quaternion by the given scalar
(that is, this := this * f).
|
void |
scale(Quaternion qwk,
float T)
Scales this quaternion by the specified fraction, using the
given quaternion as workspace -- achieved
using SLERP (spherical linear interpolation) with the identity
quaternion (representing the null rotation).
|
void |
scaleXRotationAngle(float scale)
Scales the angle of rotation in this quaternion by the given
amount, assuming this quaternion represents a rotation about
the X-axis, that is, this = (cos A/2, sin A/2, 0, 0).
|
void |
set(float[] xyzw)
Resets this Quaternion from the given component values
(in which w comes last).
|
void |
set(float ww,
float xx,
float yy,
float zz)
Resets this Quaternion from the given component values.
|
void |
set(Quaternion q)
Resets this Quaternion as a copy of the given one, q.
|
void |
setFromRotationMatrix3x3(float[] m)
Sets this quaternion from the given 3 x 3 rotation matrix
(which is in column-major order).
|
void |
setInverseUnit(Quaternion q)
Sets this Quaternion to be the inverse of the given one, q.
|
static void |
slerp(Quaternion qq,
Quaternion qa,
Quaternion qb,
Quaternion qwk,
float T)
Sets quaternion qq to be the SLERP (spherical linear
interpolation), with fraction T, between the two (unit)
quaternions qa, qb, using the given quaternion qwk as workspace.
|
Quaternion |
subtract(Quaternion q)
Returns a new Quaternion representing this - q.
|
void |
toAxisRotations(float[] result)
Computes the "Euler" angles, that is, the sequence of rotations
about the axes (roll [about X], pitch [about Y], yaw [about Z]),
corresponding to this Quaternion -- with result values in degrees.
|
void |
toFloats(float[] xyzw)
Sets the given float-array to the components of this
quaternion -- in x,y,z,w order.
|
void |
toRotationMatrix3x3(float[] m)
Sets the given 3x3 rotation matrix from this Quaternion.
|
void |
toRotationMatrix4x4(float[] m)
Sets the 3x3 rotation sub-matrix of the given 4x4 transformation
matrix from this Quaternion.
|
java.lang.String |
toString() |
float |
w()
Returns w component of this Quaternion.
|
float |
x()
Returns x component of this Quaternion.
|
float |
y()
Returns y component of this Quaternion.
|
float |
z()
Returns z component of this Quaternion.
|
public static double DEGS_TO_RADS
public static double RADS_TO_DEGS
public static Quaternion ZERO
public static Quaternion IDENTITY
public static float GS_EPSILON
public Quaternion(JAInputStream jins) throws java.io.IOException
java.io.IOException
public Quaternion(float ww, float xx, float yy, float zz)
public Quaternion()
public Quaternion(float[] xyzw)
public Quaternion(Quaternion q)
public Quaternion(float roll, float pitch, float yaw)
public void save(JAOutputStream jouts) throws java.io.IOException
java.io.IOException
public float w()
public float x()
public float y()
public float z()
public void set(Quaternion q)
public void set(float ww, float xx, float yy, float zz)
public void set(float[] xyzw)
public void setFromRotationMatrix3x3(float[] m)
public float[] asFloats()
public void toFloats(float[] xyzw)
public void toRotationMatrix4x4(float[] m)
public void toRotationMatrix3x3(float[] m)
public void fromAngleAxis(float angle, float axisX, float axisY, float axisZ)
public Quaternion add(Quaternion q)
public Quaternion subtract(Quaternion q)
public Quaternion postMultiply(Quaternion q)
public void negateEq()
public void negateXEq()
public void postMultiplyEq(Quaternion q)
public void preMultiplyEq(Quaternion q)
public void postDivideUnitEq(Quaternion q)
public Quaternion scalarMultiply(float f)
public void scalarMultiplyEq(float f)
public Quaternion negate()
public float innerProd(Quaternion q)
public float length()
public Quaternion inverse()
public Quaternion inverseUnit()
public void setInverseUnit(Quaternion q)
public void invertUnit()
public void normalize()
public void scaleXRotationAngle(float scale)
public void fromAxisRotations(float roll, float pitch, float yaw)
public void toAxisRotations(float[] result)
public void extractRotX(Quaternion qx)
public void scale(Quaternion qwk, float T)
public static void slerp(Quaternion qq, Quaternion qa, Quaternion qb, Quaternion qwk, float T)
public Quaternion log()
public Quaternion exp()
public java.lang.String toString()
toString
in class java.lang.Object