org.vizzini.math
Class Quaternion

java.lang.Object
  extended by org.vizzini.math.Quaternion
All Implemented Interfaces:
Serializable

public final class Quaternion
extends Object
implements Serializable

Provides a quaternion for handling coordinate transformations. Instances of this class are immutable.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Field Summary
static Quaternion ZERO
          Zero quaternion.
 
Constructor Summary
Quaternion(double rightAscension, double declination)
          Construct this object using the given parameters.
Quaternion(double x, double y, double z, double q)
          Construct this object with the given parameters.
Quaternion(Vector v, double angle)
          Construct this object with the given parameters.
 
Method Summary
 Quaternion conjugate()
          Return a new Quaternion which is the conjugate of this.
 boolean equals(Object object)
          Return true if this vector equals the given object.
 boolean equals(Object object, double delta)
          Return true if this vector equals the given object with the given precision.
 double getAngle()
          Return the rotation angle in radians.
 double getMagnitude()
          Return the magnitude of this.
 double getQ()
          Return the Q component.
 Vector getVector()
          Return the rotation vector.
 double getX()
          Return the X component.
 double getY()
          Return the Y component.
 double getZ()
          Return the Z component.
 int hashCode()
          Return a hash code.
 Quaternion multiply(Quaternion q)
          Return a new Quaternion which is the result of multiplying this times the given quaternion.
 Quaternion opposite()
          Return a new Quaterion that represents the opposite direction to this.
static Quaternion parseQuaternion(String quaternionString)
          Parse the given string into a Quaternion.
 Vector postMultiply(Vector v)
          Return a new Vector which is the result of multiplying the given vector with this quaternion.
 Vector preMultiply(Vector v)
          Return a new Vector which is the result of multiplying this quaternion with the given vector.
 Quaternion subtract(Quaternion q0)
          Return a new quaterion which is the difference between this and the given quaternion.
 String toRotationString()
          Return a string representation of this object using the rotation vector and rotation angle.
 String toString()
          Return a string representation of this object.
 Quaternion unit()
          Return a new unitized instance of this.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Quaternion ZERO
Zero quaternion.

Constructor Detail

Quaternion

public Quaternion(Vector v,
                  double angle)
Construct this object with the given parameters. This quaternion represents a rotation through the given angle around the given vector.

Parameters:
v - Rotation axis.
angle - Rotation angle in radians.
Since:
v0.1

Quaternion

public Quaternion(double rightAscension,
                  double declination)
Construct this object using the given parameters.

Since:
v0.1

Quaternion

public Quaternion(double x,
                  double y,
                  double z,
                  double q)
Construct this object with the given parameters.

Since:
v0.1
Method Detail

parseQuaternion

public static Quaternion parseQuaternion(String quaternionString)
Parse the given string into a Quaternion.

Since:
v0.1

conjugate

public Quaternion conjugate()
Return a new Quaternion which is the conjugate of this.

Since:
v0.1

equals

public boolean equals(Object object)
Return true if this vector equals the given object.

Overrides:
equals in class Object
Parameters:
object - Object to compare.
Since:
v0.1

equals

public boolean equals(Object object,
                      double delta)
Return true if this vector equals the given object with the given precision.

Parameters:
object - Object to compare.
delta - Allowable difference in coordinates.
Since:
v0.1

getAngle

public double getAngle()
Return the rotation angle in radians.

Since:
v0.1

getMagnitude

public double getMagnitude()
Return the magnitude of this.

Since:
v0.1

getQ

public double getQ()
Return the Q component.

Since:
v0.1

getVector

public Vector getVector()
Return the rotation vector.

Since:
v0.1

getX

public double getX()
Return the X component.

Since:
v0.1

getY

public double getY()
Return the Y component.

Since:
v0.1

getZ

public double getZ()
Return the Z component.

Since:
v0.1

hashCode

public int hashCode()
Return a hash code.

Overrides:
hashCode in class Object

multiply

public Quaternion multiply(Quaternion q)
Return a new Quaternion which is the result of multiplying this times the given quaternion.

Since:
v0.1

opposite

public Quaternion opposite()
Return a new Quaterion that represents the opposite direction to this.

Since:
v0.1

postMultiply

public Vector postMultiply(Vector v)
Return a new Vector which is the result of multiplying the given vector with this quaternion.

Since:
v0.1

preMultiply

public Vector preMultiply(Vector v)
Return a new Vector which is the result of multiplying this quaternion with the given vector.

Since:
v0.1

subtract

public Quaternion subtract(Quaternion q0)
Return a new quaterion which is the difference between this and the given quaternion.

Since:
v0.1

toRotationString

public String toRotationString()
Return a string representation of this object using the rotation vector and rotation angle.

Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1

unit

public Quaternion unit()
Return a new unitized instance of this.

Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02