public class AxisAngle extends java.lang.Object implements Clonable
The axis value is normalized. However, the representation is
still not unique: negating both axis and angle, or adding
2*PI to angle, results in the same rotation.
| Modifier and Type | Field and Description |
|---|---|
double |
angle
Angle of rotation about the axis, in radians.
|
Vector3d |
axis
Rotation axis.
|
static AxisAngle |
IDENTITY |
static AxisAngle |
ROT_X_90 |
static AxisAngle |
ROT_Y_90 |
static AxisAngle |
ROT_Z_90 |
static AxisAngle |
ZERO |
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
AxisAngle |
clone() |
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[] vals)
Gets the values associated with this AxisAngle.
|
void |
get(double[] vals,
double[] refs,
int off,
double angScale)
Copies the elements of this AxisAngle into an array of doubles.
|
void |
get(double[] vals,
double[] refs,
int off,
RotationRep rotRep,
double s)
Get a specified rotation representation from this AxisAngle.
|
void |
get(double[] vals,
int off)
Gets the values associated with this AxisAngle.
|
void |
get(Quaternion q)
Gets the quaternion associated with this axis angle.
|
void |
inverseTransform(Vector3d vr,
Vector3d v1)
Transforms a vector v1 by the rotation implied by the
inverse of this axis-angle using Rodriguez's rotation formula
|
void |
negate()
Negates the axis and angle of this AxisAngle.
|
double |
numericDistance(Vector3d axis,
double ang)
Returns the distance between this AxisAngle and a second specified by
axis and ang. |
double |
numericDistanceSquared(Vector3d axis,
double ang)
Returns the square of the distance between this AxisAngle and a second
specified by
axis and ang, where distance is
described in the docs for numericDistance(maspack.matrix.Vector3d, double). |
void |
set(AxisAngle axisAng)
Sets this AxisAngle to the values of another AxisAngle.
|
void |
set(double[] vals)
Sets this AxisAngle to the prescribed values.
|
void |
set(double[] vals,
int off)
Sets this AxisAngle to the prescribed values.
|
void |
set(double[] vals,
int off,
RotationRep rotRep,
double s)
Sets this AxisAngle from a set of doubles implementing a given rotation
representation.
|
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.
|
void |
setRandom()
Sets this AxisAngle to a random one.
|
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).
|
void |
transform(Vector3d vr,
Vector3d v1)
Transforms a vector v1 by the rotation implied by this axis-angle
using Rodriguez's rotation formula
|
public static final AxisAngle IDENTITY
public static final AxisAngle ZERO
public static final AxisAngle ROT_X_90
public static final AxisAngle ROT_Y_90
public static final AxisAngle ROT_Z_90
public Vector3d axis
public double angle
public AxisAngle()
public AxisAngle(double[] values)
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.public AxisAngle(double x,
double y,
double z,
double ang)
x - rotation axis x directiony - rotation axis y directionz - rotation axis z directionang - rotation angle, in radianspublic AxisAngle(Vector3d axis, double ang)
axis - rotation axisang - rotation angle (in radians)public AxisAngle(AxisAngle axisAng)
axisAng - AxisAngle to supply initial valuespublic AxisAngle(RotationMatrix3d R)
R - rotation matrixpublic void set(double x,
double y,
double z,
double ang)
x - rotation axis x directiony - rotation axis y directionz - rotation axis z directionang - rotation angle, in radianspublic void set(double[] vals,
int off)
vals - AxisAngle values given as an arrayoff - offset within vals where the values beginpublic void set(double[] vals)
vals - AxisAngle values given as an arraypublic void set(Vector3d axis, double ang)
axis - rotation axisang - rotation angle (in radians)public void set(AxisAngle axisAng)
axisAng - AxisAngle supplying new valuespublic void set(RotationMatrix3d R)
R - rotation matrixpublic void set(Quaternion q)
q - quaternionpublic void get(Quaternion q)
q - return the quaternionpublic void get(double[] vals,
int off)
set(double[]) for a description of the values.vals - returns the AxisAngle valuesoff - offset within vals where the values are storedpublic void get(double[] vals,
double[] refs,
int off,
double angScale)
>= 4 + off. The method accepts
an optional argument refs which specifies a reference
AxisAngle. If the negative of this AxisAngle is closer distance-wise
to the reference, then the negative values are copied instead.vals - array into which values are copiedrefs - if non-null, specifies values of a reference AxisAngleoff - offset within vals and refs where values
are storedangScale - factor by which the output and reference angles are scaledpublic void get(double[] vals)
set(double[]) for a description of the values.vals - returns the AxisAngle valuespublic void transform(Vector3d vr, Vector3d v1)
vr - result vectorv1 - vector to be transformedpublic void inverseTransform(Vector3d vr, Vector3d v1)
vr - result vectorv1 - vector to be transformedpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String fmtStr)
printf style format string.
For a description of the format string syntax, see
NumberFormat.fmtStr - numeric format specificationpublic java.lang.String toString(NumberFormat fmt)
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.fmt - numeric formatpublic boolean epsilonEquals(AxisAngle axisAng, double eps) throws ImproperSizeException
epsilon.axisAng - AxisAngle to compare witheps - comparison toleranceImproperSizeExceptionpublic void negate()
public boolean equals(AxisAngle axisAng)
axisAng - AxisAngle to compare withpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - Object to compare withpublic AxisAngle clone()
public void set(double[] vals,
int off,
RotationRep rotRep,
double s)
vals - values specifying the rotationoff - offset within vals where rotation info startsrotRep - rotation representations - factor by which values are scaledpublic void get(double[] vals,
double[] refs,
int off,
RotationRep rotRep,
double s)
vals - returns the values specifying the rotationrefs - if non-null, specifies a reference set of values to
be used to resolve non-unique solutionsoff - offset within vals where rotation info startsrotRep - rotation representations - factor by which values are scaledpublic double numericDistanceSquared(Vector3d axis, double ang)
axis and ang, where distance is
described in the docs for numericDistance(maspack.matrix.Vector3d, double).axis - axis of the AxisAngle to obtain distance squared toang - angle of AxisAngle to obtain distance squared topublic double numericDistance(Vector3d axis, double ang)
axis and ang. Distance here refers not to angular
distance between the two orientations, but distance between the
representations themselves:
d = sqrt( deltaAngle^2 + ||deltaAxis||^2 )where deltaAngle is the difference between the two angles (reduced to the range
(-PI,PI], and deltaAxis is the difference between the two
axes. In particular, an AxisAngle and its negative have maximal distance
between each other, even though both describe the same orientation.axis - axis of the AxisAngle to obtain distance toang - angle of AxisAngle to obtain distance topublic void setRandom()