maspack.matrix
Class AxisAngle

java.lang.Object
  extended by maspack.matrix.AxisAngle

public class AxisAngle
extends java.lang.Object

Axis-angle representation of a rigid-body rotation. Any spatial rotation can be represented as a rotation about a specific axis by a certain angular amount. An angle of 0 corresponds to the "identity" rotation (i.e., no rotation).

In order to keep the representation unique, the axis is normalized and the angle is kept in the range 0 <= angle < Math.PI.


Field Summary
 double angle
          Angle of rotation about the axis, in radians.
 Vector3d axis
          Rotation axis.
static AxisAngle IDENTITY
           
static AxisAngle ROT_X_90
           
 
Constructor Summary
AxisAngle()
          Creates an AxisAngle and initializes it to the identity rotation.
AxisAngle(AxisAngle axisAng)
          Creates an AxisAngle and initializes it from an existing AxisAngle.
AxisAngle(double[] values)
          Creates an AxisAngle and initializes it to the prescribed values.
AxisAngle(double x, double y, double z, double ang)
          Creates an AxisAngle and initializes it to the prescribed values.
AxisAngle(RotationMatrix3d R)
          Creates an AxisAngle initialized to the specified rotation matrix.
AxisAngle(Vector3d axis, double ang)
          Creates an AxisAngle and sets it to the prescribed values.
 
Method Summary
 boolean epsilonEquals(AxisAngle axisAng, double eps)
          Returns true if the elements of this AxisAngle equal those of another AxisAngle within a prescribed tolerance epsilon.
 boolean equals(AxisAngle axisAng)
          Returns true if the elements of this AxisAngle equal those of another AxisAngle exactly.
 boolean equals(java.lang.Object obj)
          Returns true if the supplied object is an AxisAngle and its elements equal those of this AxisAngle exactly.
 void get(double[] values)
          Gets the values associated with this AxisAngle.
 void set(AxisAngle axisAng)
          Sets this AxisAngle to the values of another AxisAngle.
 void set(double[] values)
          Sets this AxisAngle to the prescribed values.
 void set(double x, double y, double z, double ang)
          Sets this AxisAngle to the prescribed values.
 void set(Quaternion q)
          Sets this AxisAngle to the values appropriate for the specified quaternion.
 void set(RotationMatrix3d R)
          Sets this AxisAngle to the values appropriate for the specified rotation matrix.
 void set(Vector3d axis, double ang)
          Sets this AxisAngle to the prescribed values.
 java.lang.String toString()
          Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians).
 java.lang.String toString(NumberFormat fmt)
          Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians).
 java.lang.String toString(java.lang.String fmtStr)
          Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians).
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTITY

public static AxisAngle IDENTITY

ROT_X_90

public static AxisAngle ROT_X_90

axis

public Vector3d axis
Rotation axis.


angle

public double angle
Angle of rotation about the axis, in radians.

Constructor Detail

AxisAngle

public AxisAngle()
Creates an AxisAngle and initializes it to the identity rotation.


AxisAngle

public AxisAngle(double[] values)
Creates an AxisAngle and initializes it to the prescribed values. The axis values are normalized.

Parameters:
values - AxisAngle values given as an array. The x, y, and z directions of the rotation axis are given by elements 0 through 2, and the rotation angle (in radians) is given by element 3.

AxisAngle

public AxisAngle(double x,
                 double y,
                 double z,
                 double ang)
Creates an AxisAngle and initializes it to the prescribed values. The axis values are normalized.

Parameters:
x - rotation axis x direction
y - rotation axis y direction
z - rotation axis z direction
ang - rotation angle, in radians

AxisAngle

public AxisAngle(Vector3d axis,
                 double ang)
Creates an AxisAngle and sets it to the prescribed values. The axis values are normalixed.

Parameters:
axis - rotation axis
ang - rotation angle (in radians)

AxisAngle

public AxisAngle(AxisAngle axisAng)
Creates an AxisAngle and initializes it from an existing AxisAngle.

Parameters:
axisAng - AxisAngle to supply initial values

AxisAngle

public AxisAngle(RotationMatrix3d R)
Creates an AxisAngle initialized to the specified rotation matrix.

Parameters:
R - rotation matrix
Method Detail

set

public void set(double x,
                double y,
                double z,
                double ang)
Sets this AxisAngle to the prescribed values. The axis values are normalized.

Parameters:
x - rotation axis x direction
y - rotation axis y direction
z - rotation axis z direction
ang - rotation angle, in radians

set

public void set(double[] values)
Sets this AxisAngle to the prescribed values. The axis values are normalized.

Parameters:
values - AxisAngle values given as an array. The x, y, and z directions of the rotation axis are given by elements 0 through 2, and the rotation angle (in radians) is given by element 3.

set

public void set(Vector3d axis,
                double ang)
Sets this AxisAngle to the prescribed values. The axis values are normalixed.

Parameters:
axis - rotation axis
ang - rotation angle (in radians)

set

public void set(AxisAngle axisAng)
Sets this AxisAngle to the values of another AxisAngle.

Parameters:
axisAng - AxisAngle supplying new values

set

public void set(RotationMatrix3d R)
Sets this AxisAngle to the values appropriate for the specified rotation matrix.

Parameters:
R - rotation matrix

set

public void set(Quaternion q)
Sets this AxisAngle to the values appropriate for the specified quaternion.

Parameters:
q - quaternion

get

public void get(double[] values)
Gets the values associated with this AxisAngle.

Parameters:
values - returns the AxisAngle values. The x, y, and z directions of the rotation axis are given by elements 0 through 2, and the rotation angle (in radians) is given by element 3.

toString

public java.lang.String toString()
Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians).

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

toString

public java.lang.String toString(java.lang.String fmtStr)
Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians). Each element is formatted using a C printf style format string. For a description of the format string syntax, see NumberFormat.

Parameters:
fmtStr - numeric format specification
Returns:
String representation of this vector

toString

public java.lang.String toString(NumberFormat fmt)
Returns a String representation of this AxisAngle, consisting of the x, y, and z components of the axis, followed by the angle (in radians). Each element is formatted using a C printf style as decribed by the parameter NumberFormat. When called numerous times, this routine can be more efficient than toString(String), because the NumberFormat does not need to be recreated each time from a specification string.

Parameters:
fmt - numeric format
Returns:
String representation of this vector

epsilonEquals

public boolean epsilonEquals(AxisAngle axisAng,
                             double eps)
                      throws ImproperSizeException
Returns true if the elements of this AxisAngle equal those of another AxisAngle within a prescribed tolerance epsilon.

Parameters:
axisAng - AxisAngle to compare with
eps - comparison tolerance
Returns:
false if the AxisAngles are not equal within the specified tolerance
Throws:
ImproperSizeException

equals

public boolean equals(AxisAngle axisAng)
Returns true if the elements of this AxisAngle equal those of another AxisAngle exactly.

Parameters:
axisAng - AxisAngle to compare with
Returns:
false if the AxisAngles are not equal

equals

public boolean equals(java.lang.Object obj)
Returns true if the supplied object is an AxisAngle and its elements equal those of this AxisAngle exactly.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare with
Returns:
false if the Object does not equal this AxisAngle