com.jme.math
Class TransformQuaternion

java.lang.Object
  extended by com.jme.math.TransformQuaternion
All Implemented Interfaces:
Savable, java.io.Serializable, java.lang.Cloneable

public class TransformQuaternion
extends java.lang.Object
implements java.io.Serializable, Savable, java.lang.Cloneable

Started Date: Jul 16, 2004

Same as TransformMatrix, but stores rotations as quats, not Matrix3f. This is faster for interpolation, but slower than a matrix using Matrix3f for rotation when doing point translation.

Author:
Jack Lindamood, Joshua Slack
See Also:
Serialized Form

Constructor Summary
TransformQuaternion()
           
 
Method Summary
 void applyToSpatial(Spatial spatial)
          Applies the values of this matrix to the given Spatial.
 TransformQuaternion clone()
           
 TransformQuaternion combineWithParent(TransformQuaternion parent)
          Changes the values of this matrix acording to it's parent.
 boolean equals(java.lang.Object oIn)
           
 java.lang.Class<? extends TransformQuaternion> getClassTag()
           
 Quaternion getRotation()
          Return the rotation quaternion in this matrix.
 Quaternion getRotation(Quaternion quat)
          Stores this rotation value into the given Quaternion.
 Vector3f getScale()
          Return the scale vector in this matrix.
 Vector3f getScale(Vector3f scale)
          Stores this scale value into the given vector3f.
 Vector3f getTranslation()
          Return the translation vector in this matrix.
 Vector3f getTranslation(Vector3f trans)
          Stores this translation value into the given vector3f.
 int hashCode()
           
 void interpolateTransforms(TransformQuaternion t1, TransformQuaternion t2, float delta)
          Sets this matrix to the interpolation between the first matrix and the second by delta amount.
 void loadIdentity()
          Loads the identity.
 void read(JMEImporter e)
           
 void set(TransformQuaternion matrixQuat)
          Sets this matrix to be equal to the given matrix.
 void setRotationQuaternion(Quaternion rot)
          Sets this rotation to the given Quaternion value by copying.
 void setScale(float x, float y, float z)
          Sets this matrix's scale to the given x,y,z values.
 void setScale(Vector3f scale)
          Sets this scale to the given value by copying.
 void setTranslation(float x, float y, float z)
          Sets this matrix's translation to the given x,y,z values.
 void setTranslation(Vector3f trans)
          Sets this translation to the given value by copying.
 java.lang.String toString()
          toString returns the string representation of this object.
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformQuaternion

public TransformQuaternion()
Method Detail

setRotationQuaternion

public void setRotationQuaternion(Quaternion rot)
Sets this rotation to the given Quaternion value by copying.

Parameters:
rot - The new rotation for this matrix.

setTranslation

public void setTranslation(Vector3f trans)
Sets this translation to the given value by copying.

Parameters:
trans - The new translation for this matrix.

getTranslation

public Vector3f getTranslation()
Return the translation vector in this matrix.

Returns:
translation vector.

setScale

public void setScale(Vector3f scale)
Sets this scale to the given value by copying.

Parameters:
scale - The new scale for this matrix.

getScale

public Vector3f getScale()
Return the scale vector in this matrix.

Returns:
scale vector.

getTranslation

public Vector3f getTranslation(Vector3f trans)
Stores this translation value into the given vector3f. If trans is null, a new vector3f is created to hold the value. The value, once stored, is returned.

Parameters:
trans - The store location for this matrix's translation.
Returns:
The value of this matrix's translation.

getRotation

public Quaternion getRotation(Quaternion quat)
Stores this rotation value into the given Quaternion. If quat is null, a new Quaternion is created to hold the value. The value, once stored, is returned.

Parameters:
quat - The store location for this matrix's rotation.
Returns:
The value of this matrix's rotation.

getRotation

public Quaternion getRotation()
Return the rotation quaternion in this matrix.

Returns:
rotation quaternion.

getScale

public Vector3f getScale(Vector3f scale)
Stores this scale value into the given vector3f. If scale is null, a new vector3f is created to hold the value. The value, once stored, is returned.

Parameters:
scale - The store location for this matrix's scale.
Returns:
The value of this matrix's scale.

interpolateTransforms

public void interpolateTransforms(TransformQuaternion t1,
                                  TransformQuaternion t2,
                                  float delta)
Sets this matrix to the interpolation between the first matrix and the second by delta amount.

Parameters:
t1 - The begining transform.
t2 - The ending transform.
delta - An amount between 0 and 1 representing how far to interpolate from t1 to t2.

combineWithParent

public TransformQuaternion combineWithParent(TransformQuaternion parent)
Changes the values of this matrix acording to it's parent. Very similar to the concept of Node/Spatial transforms.

Parameters:
parent - The parent matrix.
Returns:
This matrix, after combining.

applyToSpatial

public void applyToSpatial(Spatial spatial)
Applies the values of this matrix to the given Spatial.

Parameters:
spatial - The spatial to be affected by this matrix.

setTranslation

public void setTranslation(float x,
                           float y,
                           float z)
Sets this matrix's translation to the given x,y,z values.

Parameters:
x - This matrix's new x translation.
y - This matrix's new y translation.
z - This matrix's new z translation.

setScale

public void setScale(float x,
                     float y,
                     float z)
Sets this matrix's scale to the given x,y,z values.

Parameters:
x - This matrix's new x scale.
y - This matrix's new y scale.
z - This matrix's new z scale.

loadIdentity

public void loadIdentity()
Loads the identity. Equal to translation=1,1,1 scale=0,0,0 rot=0,0,0,1.


set

public void set(TransformQuaternion matrixQuat)
Sets this matrix to be equal to the given matrix.

Parameters:
matrixQuat - The matrix to be equal to.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class<? extends TransformQuaternion> getClassTag()
Specified by:
getClassTag in interface Savable

clone

public TransformQuaternion clone()
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object oIn)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
toString returns the string representation of this object. It is simply a toString() call of the rotational matrix and the translational vector

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this object.