net.jinx.slowmath
Class Quaternion

java.lang.Object
  extended by net.jinx.slowmath.Quaternion

public class Quaternion
extends java.lang.Object


Constructor Summary
Quaternion()
           
Quaternion(Real[] vec)
          Constructs a new Quaternion with the given W/X/Y/Z coordinates.
Quaternion(Real x, Real y, Real z, Real w)
          Constructs a new Quaternion with the given W/X/Y/Z coordinates.
Quaternion(java.lang.String s)
          Constructs a new Quaternion by parsing the given String.
Quaternion(Vector v, Real w)
           
 
Method Summary
 Quaternion add(Quaternion q)
           
 Quaternion add(Real n)
           
 Quaternion conjugate()
           
 Quaternion divide(Quaternion q)
           
 Quaternion divide(Real n)
           
 Vector getV()
           
 Real getW()
          Provides the W coordinate.
 Real getX()
          Provides the X coordinate.
 Real getY()
          Provides the Y coordinate.
 Real getZ()
          Provides the Z coordinate.
 Quaternion invert()
           
 Real magnitude()
           
 Quaternion multiply(Quaternion q2)
           
 Quaternion multiply(Real n)
           
 Quaternion normalize()
           
 Quaternion subtract(Quaternion q)
           
 Quaternion subtract(Real n)
           
 double[] toDoubleArray()
          Converts this Quaternion to a double array.
 float[] toFloatArray()
          Converts this Quaternion to a float array.
 java.lang.String toString()
          Provides a String representation of this Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Quaternion

public Quaternion()

Quaternion

public Quaternion(Real x,
                  Real y,
                  Real z,
                  Real w)
Constructs a new Quaternion with the given W/X/Y/Z coordinates.

Parameters:
w - the W coordinate.
x - the X coordinate.
y - the Y coordinate.
z - the Z coordinate.

Quaternion

public Quaternion(Real[] vec)
Constructs a new Quaternion with the given W/X/Y/Z coordinates.

Parameters:
vec - the coordinates in an array.

Quaternion

public Quaternion(Vector v,
                  Real w)

Quaternion

public Quaternion(java.lang.String s)
Constructs a new Quaternion by parsing the given String. This uses the MathUtil class to parse Real objects for the coordinates in a type-neutral manner.

Parameters:
s - the String to parse.
Method Detail

getW

public Real getW()
Provides the W coordinate.

Returns:
the W coordinate.

getV

public Vector getV()

getX

public Real getX()
Provides the X coordinate.

Returns:
the X coordinate.

getY

public Real getY()
Provides the Y coordinate.

Returns:
the Y coordinate.

getZ

public Real getZ()
Provides the Z coordinate.

Returns:
the Z coordinate.

add

public Quaternion add(Real n)

add

public Quaternion add(Quaternion q)

subtract

public Quaternion subtract(Real n)

subtract

public Quaternion subtract(Quaternion q)

multiply

public Quaternion multiply(Real n)

multiply

public Quaternion multiply(Quaternion q2)

conjugate

public Quaternion conjugate()

invert

public Quaternion invert()

divide

public Quaternion divide(Real n)

divide

public Quaternion divide(Quaternion q)

magnitude

public Real magnitude()

normalize

public Quaternion normalize()

toFloatArray

public float[] toFloatArray()
Converts this Quaternion to a float array.

Returns:
the float array.

toDoubleArray

public double[] toDoubleArray()
Converts this Quaternion to a double array.

Returns:
the double array.

toString

public java.lang.String toString()
Provides a String representation of this Vector.

Overrides:
toString in class java.lang.Object
Returns:
the String.