mil.navy.nps.math
Class Quaternion2

java.lang.Object
  extended bymil.navy.nps.math.Quaternion2

public class Quaternion2
extends java.lang.Object

The Quaternion2 class executes quaternion operations.

Version:
1.0 13 Dec 98 DIS VRML - OpenGl +---------->x ^y /| | / | | / | ======> | y | +-------------->x z / / / z
Author:
Ildeniz Duman

Constructor Summary
Quaternion2()
          Default constructor
Quaternion2(java.lang.String myName)
          Default constructor
Quaternion2(java.lang.String myName, double ww, double xx, double yy, double zz)
          Default constructor
 
Method Summary
 Quaternion2 add(Quaternion2 QUAT)
          Adds two quaternions
 double dotProduct(Quaternion2 QUAT5)
          Finds the dot product of two quaternions
 double getW()
          Returns the w value of quaternion.
 double getX()
          Returns the x value of quaternion.
 double getY()
          Returns the y value of quaternion.
 double getZ()
          Returns the z value of quaternion.
 Quaternion2 invert()
          Finds the inverse (conjugate) of a quaternion
static void main(java.lang.String[] ags)
          Main method for testing
 Quaternion2 multiply(double NUM)
          Multiplies this quaternion with a scalar
 Quaternion2 multiply(Quaternion2 QUAT)
          Multiplies two quaternions
 void normalize()
          Normalizes the quaternion modifies the current quaternion
 Quaternion2 rotate(Quaternion2 QUAT4)
          Rotates a vector by quaternions
 void setQuaternion2(double ww, double xx, double yy, double zz)
          Sets the quaternion values
 Quaternion2 substract(Quaternion2 QUAT)
          Substracts two quaternions
 Quaternion2 toAxisAngles()
          Calculates the axis angles of quaternion for drawing, results must be used in glRotatef() by using get() functions
 Quaternion2 toBody(Quaternion2 QUAT)
          Converts to body coordinates
 Quaternion2 toEulerAngles()
          Converts a quaternion into Euler angles Warning : This conversion is inherently ill-defined
 float[] toFloat()
          Converts quaternion's values into float
 Quaternion2 toQuaternion2()
          Calculates the quaternion value of three rotations Current object is a 3D vector with rotation angles in quaternion form
 java.lang.String toString()
          Overrides the toString method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Quaternion2

public Quaternion2(java.lang.String myName,
                   double ww,
                   double xx,
                   double yy,
                   double zz)
Default constructor

Parameters:
myName - Name of the quaternion
ww - w value of the quaternion
xx - x value of the quaternion
yy - y value of the quaternion
zz - z value of the quaternion

Quaternion2

public Quaternion2(java.lang.String myName)
Default constructor

Parameters:
myName - Name of the quaternion

Quaternion2

public Quaternion2()
Default constructor

Method Detail

setQuaternion2

public void setQuaternion2(double ww,
                           double xx,
                           double yy,
                           double zz)
Sets the quaternion values

Parameters:
ww - w value of the quaternion
xx - x value of the quaternion
yy - y value of the quaternion
zz - z value of the quaternion

getW

public double getW()
Returns the w value of quaternion.


getX

public double getX()
Returns the x value of quaternion.


getY

public double getY()
Returns the y value of quaternion.


getZ

public double getZ()
Returns the z value of quaternion.


multiply

public Quaternion2 multiply(Quaternion2 QUAT)
Multiplies two quaternions

Parameters:
QUAT - second quaternion
Returns:
new Quaternion2

multiply

public Quaternion2 multiply(double NUM)
Multiplies this quaternion with a scalar

Parameters:
NUM - is a scalar
Returns:
modified Quaternion2

add

public Quaternion2 add(Quaternion2 QUAT)
Adds two quaternions

Parameters:
QUAT - is a quaternion to add
Returns:
new Quaternion2

substract

public Quaternion2 substract(Quaternion2 QUAT)
Substracts two quaternions

Parameters:
QUAT - is a quaternion to substract
Returns:
new Quaternion2

invert

public Quaternion2 invert()
Finds the inverse (conjugate) of a quaternion

Returns:
new Quaternion2

rotate

public Quaternion2 rotate(Quaternion2 QUAT4)
Rotates a vector by quaternions

Parameters:
QUAT4 - a vector in quaternion form
Returns:
Rotated vector in quaternion form

toBody

public Quaternion2 toBody(Quaternion2 QUAT)
Converts to body coordinates

Parameters:
QUAT - a vector in quaternion form to convert to body coordinates
Returns:
Converted vector in quaternion form

dotProduct

public double dotProduct(Quaternion2 QUAT5)
Finds the dot product of two quaternions

Parameters:
QUAT5 - a quaternion
Returns:
Dot product value

normalize

public void normalize()
Normalizes the quaternion modifies the current quaternion


toAxisAngles

public Quaternion2 toAxisAngles()
Calculates the axis angles of quaternion for drawing, results must be used in glRotatef() by using get() functions

Returns:
Result in quaternion form

toQuaternion2

public Quaternion2 toQuaternion2()
Calculates the quaternion value of three rotations Current object is a 3D vector with rotation angles in quaternion form

Returns:
new Quaternion2

toEulerAngles

public Quaternion2 toEulerAngles()
Converts a quaternion into Euler angles Warning : This conversion is inherently ill-defined

Returns:
new Quaternion2

toString

public java.lang.String toString()
Overrides the toString method

Returns:
String object

toFloat

public float[] toFloat()
Converts quaternion's values into float

Returns:
Float []

main

public static void main(java.lang.String[] ags)
Main method for testing