maspack.matrix
Class AxisAngle

java.lang.Object
  extended bymaspack.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.
 
Constructor Summary
AxisAngle()
          Creates an AxisAngle and initializes it to the identity rotation.
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(Vector3d axis, double ang)
          Creates an AxisAngle and sets it to the prescribed values.
 
Method Summary
 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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)
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(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

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).

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 formated 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 formated 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