|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.math.Quaternion
Quaternion
defines a single example of a more general class of
hypercomplex numbers. Quaternions extends a rotation in three dimensions to
a rotation in four dimensions. This avoids "gimbal lock" and allows for
smooth continuous rotation.
Quaternion
is defined by four floating point numbers:
{x y z w}.
Field Summary | |
float |
w
|
float |
x
|
float |
y
|
float |
z
|
Constructor Summary | |
Quaternion()
Constructor instantiates a new Quaternion object
initializing all values to zero. |
|
Quaternion(float[] angles)
Constructor instantiates a new Quaternion object from
a collection of rotation angles. |
|
Quaternion(float x,
float y,
float z,
float w)
Constructor instantiates a new Quaternion object
from the given list of parameters. |
|
Quaternion(Quaternion q)
Constructor instantiates a new Quaternion object from
an existing quaternion, creating a copy. |
|
Quaternion(Quaternion q1,
Quaternion q2,
float interp)
Constructor instantiates a new Quaternion object from
an interpolation between two other quaternions. |
Method Summary | |
Quaternion |
add(Quaternion q)
add adds the values of this quaternion to those
of the parameter quaternion. |
float |
dot(Quaternion q)
dot calculates and returns the dot product of this
quaternion with that of the parameter quaternion. |
void |
fromAngleAxis(float angle,
Vector axis)
fromAngleAxis sets this quaternion to the values
specified by an angle and an axis of rotation. |
void |
fromAngles(float[] angles)
fromAngles builds a quaternion from the Euler rotation
angles (x,y,z). |
void |
fromMatrix(float[] matrix,
int rowColumnCount)
fromMatrix creates a quaternion from the rotational
matrix. |
Quaternion |
inverse()
inverse returns the inverse of this quaternion as
a new quaternion. |
static void |
main(java.lang.String[] args)
|
Quaternion |
mult(float scalar)
mult multiplies this quaternion by a parameter
scalar. |
Quaternion |
mult(Quaternion q)
mult multiplies this quaternion by a parameter
quaternion. |
void |
negate()
negate inverts the values of the quaternion. |
float |
norm()
norm returns the norm of this quaternion. |
Quaternion |
slerp(Quaternion q1,
Quaternion q2,
float t)
slerp sets this quaternion's value as an interpolation
between two other quaternions. |
Quaternion |
subtract(Quaternion q)
subtract subtracts the values of the parameter
quaternion from those of this quaternion. |
float |
toAngleAxis(Vector axis)
toAngleAxis sets a given angle and axis to that
represented by the current quaternion. |
float[] |
toMatrix()
getMatrix converts the values of this quaternion into
a 4x4 matrix. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public float x
public float y
public float z
public float w
Constructor Detail |
public Quaternion()
Quaternion
object
initializing all values to zero.
public Quaternion(float x, float y, float z, float w)
Quaternion
object
from the given list of parameters.
x
- the x value of the quaternion.y
- the y value of the quaternion.z
- the z value of the quaternion.w
- the w value of the quaternion.public Quaternion(float[] angles)
Quaternion
object from
a collection of rotation angles.
angles
- the angles of rotation that will define the
Quaternion
.public Quaternion(Quaternion q1, Quaternion q2, float interp)
Quaternion
object from
an interpolation between two other quaternions.
q1
- the first quaternion.q2
- the second quaternion.interp
- the amount to interpolate between the two quaternions.public Quaternion(Quaternion q)
Quaternion
object from
an existing quaternion, creating a copy.
q
- the quaternion to copy.Method Detail |
public void fromAngles(float[] angles)
fromAngles
builds a quaternion from the Euler rotation
angles (x,y,z).
angles
- the Euler angles of rotation.public void fromAngleAxis(float angle, Vector axis)
fromAngleAxis
sets this quaternion to the values
specified by an angle and an axis of rotation.
angle
- the angle to rotate.axis
- the axis of rotation.public void fromMatrix(float[] matrix, int rowColumnCount)
fromMatrix
creates a quaternion from the rotational
matrix. A quaternion can be created from a 3x3 or 4x4 matrix. If
a 3x3 matrix is passed, it will be converted into a 4x4.
matrix
- the matrix to generate the quaternion from.rowColumnCount
- the number of rows/colums (3 or 4).public float[] toMatrix()
getMatrix
converts the values of this quaternion into
a 4x4 matrix.
public float toAngleAxis(Vector axis)
toAngleAxis
sets a given angle and axis to that
represented by the current quaternion. The values are stored
as following: The axis is provided as a parameter and built
by the method, the angle is returned as a float.
axis
- the object to contain the axis.
public Quaternion slerp(Quaternion q1, Quaternion q2, float t)
slerp
sets this quaternion's value as an interpolation
between two other quaternions.
q1
- the first quaternion.q2
- the second quaternion.public Quaternion add(Quaternion q)
add
adds the values of this quaternion to those
of the parameter quaternion. The result is returned as a new
quaternion.
q
- the quaternion to add to this.
public Quaternion subtract(Quaternion q)
subtract
subtracts the values of the parameter
quaternion from those of this quaternion. The result is
returned as a new quaternion.
q
- the quaternion to subtract from this.
public Quaternion mult(Quaternion q)
mult
multiplies this quaternion by a parameter
quaternion. The result is returned as a new quaternion. It should
be noted that quaternion multiplication is not cummulative so
q * p != p * q.
q
- the quaternion to multiply this quaternion by.
public Quaternion mult(float scalar)
mult
multiplies this quaternion by a parameter
scalar. The result is returned as a new quaternion.
public float dot(Quaternion q)
dot
calculates and returns the dot product of this
quaternion with that of the parameter quaternion.
q
- the quaternion to calculate the dot product of.
public float norm()
norm
returns the norm of this quaternion. This is
the dot product of this quaternion with itself.
public Quaternion inverse()
inverse
returns the inverse of this quaternion as
a new quaternion. If this quaternion does not have an inverse
(if it's norma is 0 or less), then null is returned.
public void negate()
negate
inverts the values of the quaternion.
public static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |