Jeospace API

org.jeospace.coordinate
Class Quaternion

java.lang.Object
  extended byorg.jeospace.coordinate.Quaternion
All Implemented Interfaces:
java.lang.Cloneable

public class Quaternion
extends java.lang.Object
implements java.lang.Cloneable

A normalized quaternion implemented with double precision floating point values.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Attitude, AxisAngle, Vector

Constructor Summary
Quaternion()
          Construct an identity quaternion - initialized to (0.0, 0.0, 0.0, 1.0)
Quaternion(Attitude attitude)
          Construct a quaternion that cooresponds to the argument Attitude.
Quaternion(AxisAngle a)
          Construct a quaternion initialized to the given value and normalized
Quaternion(double[] quat)
          Construct a quaternion initialized to the given value and normalized
Quaternion(double x, double y, double z, double w)
          Construct a quaternion initialized to the given value and normalized
Quaternion(Quaternion quat)
          Construct a quaternion initialized to duplicate the argument
Quaternion(Vector axis, double angle)
          Construct a quaternion initialized to the given value and normalized
 
Method Summary
 double angle(Quaternion quat)
          Return the angular separation of this quaternion and the argument in units of radians.
 java.lang.Object clone()
          Return a clone of the quaternion
 void conjugate()
          Set the value of this quaternion to it's conjugate (or inverse)
 double dot(Quaternion quat)
          Return the value of the dot product of this quaternion and the argument
 boolean equals(java.lang.Object obj)
          Check the quaternion for equality with the passed object.
 void get(Attitude a)
          Initialize the argument Attitude object to correspond to the quaternion oriented per the DefaultConvention.
 void get(AxisAngle a)
          Return the value of the quaternion as an axis angle
 void get(double[] quat)
          Return the value of the quaternion
 void get(Quaternion quat)
          Return the value of the quaternion
 double get(Vector axis)
          Return the value of the quaternion
 Attitude getAttitude()
          Return an Attitude object that corresponds to the quaternion oriented per the DefaultConvention.
 AxisAngle getAxisAngle()
          Return an AxisAngle object that corresponds to the quaternion
 int hashCode()
          Calculate the hash code
 double magnitude()
          Return the magnitude of the quaternion
 void mult(Quaternion quat)
          Set the value of this quaternion multiplied by the argument
 void set(Attitude attitude)
          Set the value of the quaternion to coorespond to the argument Attitude.
 void set(AxisAngle a)
          Set the value of the quaternion initialized to the given value and normalize
 void set(double[] quat)
          Set the value of the quaternion and normalize
 void set(double x, double y, double z, double w)
          Set the value of the quaternion and normalize
 void set(Quaternion quat)
          Set the value of the quaternion to duplicate the argument
 void set(Vector axis, double angle)
          Set the value of the quaternion and normalize
 java.lang.String toString()
          Return a string representing the quaternion of the form "x, y, z, w"
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Quaternion

public Quaternion()
Construct an identity quaternion - initialized to (0.0, 0.0, 0.0, 1.0)


Quaternion

public Quaternion(double x,
                  double y,
                  double z,
                  double w)
Construct a quaternion initialized to the given value and normalized

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

Quaternion

public Quaternion(double[] quat)
Construct a quaternion initialized to the given value and normalized

Parameters:
quat - the double array of values

Quaternion

public Quaternion(Quaternion quat)
Construct a quaternion initialized to duplicate the argument

Parameters:
quat - the Quaternion object to duplicate

Quaternion

public Quaternion(Vector axis,
                  double angle)
Construct a quaternion initialized to the given value and normalized

Parameters:
axis - the Vector axis of rotation
angle - the rotation in radians about the axis

Quaternion

public Quaternion(AxisAngle a)
Construct a quaternion initialized to the given value and normalized

Parameters:
a - the AxisAngle representation of the rotation

Quaternion

public Quaternion(Attitude attitude)
Construct a quaternion that cooresponds to the argument Attitude.

Note: the conversion is specific to the DefaultConvention. The orientation axis' are:
yaw - about the Y axis
pitch - about the X axis
roll - about the Z axis

Parameters:
attitude - the Attitude object to convert
Method Detail

set

public void set(Vector axis,
                double angle)
Set the value of the quaternion and normalize

Parameters:
axis - the Vector axis of rotation
angle - the rotation in radians about the axis

get

public double get(Vector axis)
Return the value of the quaternion

Parameters:
axis - the Vector object to initialize with the axis of rotation
Returns:
the rotation in radians about the axis

set

public void set(AxisAngle a)
Set the value of the quaternion initialized to the given value and normalize

Parameters:
a - the AxisAngle representation of the rotation

get

public void get(AxisAngle a)
Return the value of the quaternion as an axis angle

Parameters:
a - the AxisAngle to initialize

getAxisAngle

public AxisAngle getAxisAngle()
Return an AxisAngle object that corresponds to the quaternion

Returns:
the AxisAngle object that corresponds to the quaternion

set

public void set(Attitude attitude)
Set the value of the quaternion to coorespond to the argument Attitude.

Note: the conversion is specific to the DefaultConvention. The orientation axis' are:
yaw - about the Y axis
pitch - about the X axis
roll - about the Z axis

Parameters:
attitude - the Attitude object to convert

get

public void get(Attitude a)
Initialize the argument Attitude object to correspond to the quaternion oriented per the DefaultConvention.

Parameters:
a - the Attitude object to initialize from the quaternion

getAttitude

public Attitude getAttitude()
Return an Attitude object that corresponds to the quaternion oriented per the DefaultConvention.

Returns:
the Attitude object that corresponds to the quaternion

set

public void set(double x,
                double y,
                double z,
                double w)
Set the value of the quaternion and normalize

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

set

public void set(double[] quat)
Set the value of the quaternion and normalize

Parameters:
quat - the double array of values

get

public void get(double[] quat)
Return the value of the quaternion

Parameters:
quat - the double array to initialize

set

public void set(Quaternion quat)
Set the value of the quaternion to duplicate the argument

Parameters:
quat - the Quaternion object to duplicate

get

public void get(Quaternion quat)
Return the value of the quaternion

Parameters:
quat - the Quaternion object to initialize

mult

public void mult(Quaternion quat)
Set the value of this quaternion multiplied by the argument

Parameters:
quat - the multiplier

dot

public double dot(Quaternion quat)
Return the value of the dot product of this quaternion and the argument

Parameters:
quat - the argument quaternion
Returns:
the dot product

angle

public double angle(Quaternion quat)
Return the angular separation of this quaternion and the argument in units of radians. The value returned reflects the shortest path rotation from this quaternion to the argument, therefore the return value will always be 0 <= value <= Math.PI.

Parameters:
quat - the argument quaternion
Returns:
the angular separation in units of radians

conjugate

public void conjugate()
Set the value of this quaternion to it's conjugate (or inverse)


magnitude

public double magnitude()
Return the magnitude of the quaternion

Returns:
the magnitude

clone

public java.lang.Object clone()
Return a clone of the quaternion

Returns:
a fully duplicated Quaternion object

hashCode

public int hashCode()
Calculate the hash code

Returns:
the hash code

equals

public boolean equals(java.lang.Object obj)
Check the quaternion for equality with the passed object.

Returns:
true if the values of the quaternion are identical, false otherwise

toString

public java.lang.String toString()
Return a string representing the quaternion of the form "x, y, z, w"

Returns:
the string representation of the quaternion

Jeospace API

Copyright © 2006 - jeospace.org