m3g12
Class Quaternion

java.lang.Object
  extended by m3g12.Quaternion

public class Quaternion
extends java.lang.Object

Quaternion implementation.

Author:
Claus Hoefele

Field Summary
private  float w
          Quaternion element.
private  float x
          Quaternion element.
private  float y
          Quaternion element.
private  float z
          Quaternion element.
 
Constructor Summary
Quaternion()
          Creates a new quaternion and initializes it to the identity.
Quaternion(float x, float y, float z, float w)
          Creates a new quaternion and initializes it to the given values.
 
Method Summary
 float getW()
          Getter for w value.
 float getX()
          Getter for x value.
 float getY()
          Getter for y value.
 float getZ()
          Getter for z value.
 Quaternion normalize()
          Normalizes this quaternion.
 Quaternion postMultiply(Quaternion rhs)
          Multiplies this quaternion from the right by the given quaternion.
 void set(float x, float y, float z, float w)
          Sets this quaternion to the given values.
 Quaternion setAxisAngle(float angle, float ax, float ay, float az)
          Sets the values of this quaternion by converting the given axis-angle values.
 Quaternion setEuler(float rx, float ry, float rz)
          Sets the values of this quaternion by converting the given Euler angles.
 void setIdentity()
          Resets this quaternion to the identity.
 java.lang.String toString()
          Returns a String representation of this class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

private float x
Quaternion element.


y

private float y
Quaternion element.


z

private float z
Quaternion element.


w

private float w
Quaternion element.

Constructor Detail

Quaternion

public Quaternion()
Creates a new quaternion and initializes it to the identity.


Quaternion

public Quaternion(float x,
                  float y,
                  float z,
                  float w)
Creates a new quaternion and initializes it to the given values.

Parameters:
x - x value.
y - y value.
z - z value.
w - w value.
Method Detail

setIdentity

public void setIdentity()
Resets this quaternion to the identity.


set

public void set(float x,
                float y,
                float z,
                float w)
Sets this quaternion to the given values.

Parameters:
x - x value.
y - y value.
z - z value.
w - w value.

getX

public float getX()
Getter for x value.

Returns:
x value.

getY

public float getY()
Getter for y value.

Returns:
y value.

getZ

public float getZ()
Getter for z value.

Returns:
z value.

getW

public float getW()
Getter for w value.

Returns:
w value.

setAxisAngle

public Quaternion setAxisAngle(float angle,
                               float ax,
                               float ay,
                               float az)
Sets the values of this quaternion by converting the given axis-angle values.

Parameters:
angle - angle of rotation around the axis, in degrees.
ax - x component of the rotation axis.
ay - y component of the rotation axis.
az - z component of the rotation axis.
Returns:
reference to this quaternion.

setEuler

public Quaternion setEuler(float rx,
                           float ry,
                           float rz)
Sets the values of this quaternion by converting the given Euler angles. The resulting quaternion is in the order qx*qy*qz.

Parameters:
rx - angle of rotation around x axis, in degrees.
ry - angle of rotation around y axis, in degrees.
rz - angle of rotation around z axis, in degrees.
Returns:
reference to this quaternion.

postMultiply

public Quaternion postMultiply(Quaternion rhs)
Multiplies this quaternion from the right by the given quaternion.

Parameters:
rhs - the right hand side quaternion.
Returns:
reference to this quaternion.

normalize

public Quaternion normalize()
Normalizes this quaternion.

Returns:
reference to this quaternion.

toString

public java.lang.String toString()
Returns a String representation of this class.

Overrides:
toString in class java.lang.Object
Returns:
string representation.