Simbody
|
This class, along with its sister class CoordinateDirection, provides convenient manipulation of the three coordinate axes via the definition of three constants XAxis, YAxis, and ZAxis each with a unique subtype and implicit conversion to the integers 0, 1, and 2 whenever necessary. Methods are provided to allow code to be written once that can be used to work with the axes in any order. More...
#include <CoordinateAxis.h>
Classes | |
class | XCoordinateAxis |
class | YCoordinateAxis |
class | ZCoordinateAxis |
Public Member Functions | |
CoordinateAxis (int i) | |
Explicit construction of a CoordinateAxis from a calculated integer that must be 0, 1, or 2 representing XAxis, YAxis, or ZAxis. | |
operator int () const | |
Implicit conversion of a CoordinateAxis to int 0, 1, or 2. | |
CoordinateAxis | getNextAxis () const |
Return the "next" coordinate axis after this one:
| |
CoordinateAxis | getPreviousAxis () const |
Return the "previous" coordinate axis before this one:
| |
CoordinateAxis | getThirdAxis (const CoordinateAxis &axis2) const |
Given this coordinate axis and one other, return the missing one:
| |
bool | isXAxis () const |
Return true if this is the X axis. | |
bool | isYAxis () const |
Return true if this is the Y axis. | |
bool | isZAxis () const |
Return true if this is the Z axis. | |
bool | isNextAxis (const CoordinateAxis &axis2) const |
Return true if the given axis2 is the one following this one as would be reported by getNextAxis(). | |
bool | isPreviousAxis (const CoordinateAxis &axis2) const |
Return true if the given axis2 is the one preceding this one as would be reported by getPreviousAxis(). | |
bool | isSameAxis (const CoordinateAxis &axis2) const |
Return true if the given axis2 is the same as this one. You can use operator==() to perform the same comparison. | |
bool | areAllSameAxes (const CoordinateAxis &axis2, const CoordinateAxis &axis3) const |
Return true if both axis2 and axis3 are the same as this one. | |
bool | isDifferentAxis (const CoordinateAxis &axis2) const |
Return true if the given axis2 is not the same one as this one. You can use operator!=() to perform the same comparison. | |
bool | areAllDifferentAxes (const CoordinateAxis &axis2, const CoordinateAxis &axis3) const |
Return true if neither axis2 nor axis3 is the same as this axis nor each other; that is, (this,axis2,axis3) together cover all three axes. | |
bool | isForwardCyclical (const CoordinateAxis &axis2) const |
Return true if the given axis2 is the one following this one in a forward cyclical direction, that is, if axis2 is the one that would be reported by getNextAxis(). | |
bool | isReverseCyclical (const CoordinateAxis &axis2) const |
Return true if the given axis2 is the one following this one in a reverse cyclical direction, that is, if axis2 is the one that would be reported by getPreviousAxis(). | |
int | dotProduct (const CoordinateAxis &axis2) const |
Perform a specialized dot product between this axis and axis2; returning one if they are the same axis and zero otherwise, without performing any floating point operations. | |
int | crossProductSign (const CoordinateAxis &axis2) const |
Return the sign that would result from a cross product between this axis and axis2: zero if axis2 is the same as this axis; one if the result would be in the positive direction along the third axis; -1 if it would be in the negative direction. | |
CoordinateAxis | crossProductAxis (const CoordinateAxis &axis2) const |
Return the coordinate axis along which the cross product of this axis and axis2 would lie: same as this if axis2 is the same as this axis (doesn't matter because the sign would be zero); otherwise, the third axis that is neither this one nor axis2. | |
CoordinateAxis | crossProduct (const CoordinateAxis &axis2, int &sign) const |
Return the axis and sign along that axis that would result from a cross product between this axis and axis2; this combines the functions of both crossProductAxis() and crossProductSign(). | |
Static Public Member Functions | |
static const CoordinateAxis & | getCoordinateAxis (int i) |
Return a reference to the CoordinateAxis constant XAxis, YAxis, or ZAxis corresponding to the given integer index which must be 0, 1, or 2. | |
static bool | isIndexInRange (int i) |
Return true if the given integer is suitable as a coordinate axis, meaning it is one of 0, 1, or 2 designating XAxis, YAxis, or ZAxis, respectively. | |
static void | assertIndexIsInRange (int i) |
When in Debug mode, throw an assertion if the given integer is not suited as a coordinate axis, as defined by isIndexInRange(). | |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const CoordinateAxis &a1, const CoordinateAxis &a2) |
Compare two CoordinateAxis objects. | |
bool | operator!= (const CoordinateAxis &a1, const CoordinateAxis &a2) |
Compare two CoordinateAxis objects. | |
const CoordinateDirection::NegXDirection & | operator- (const CoordinateAxis::XCoordinateAxis &) |
Create the NegXAxis direction by negating XAxis. | |
const CoordinateDirection::NegYDirection & | operator- (const CoordinateAxis::YCoordinateAxis &) |
Create the NegYAxis direction by negating YAxis. | |
const CoordinateDirection::NegZDirection & | operator- (const CoordinateAxis::ZCoordinateAxis &) |
Create the NegZAxis direction by negating ZAxis. | |
CoordinateDirection | operator- (const CoordinateAxis &axis) |
Create the negative direction along the given axis. | |
CoordinateDirection | operator+ (const CoordinateAxis &axis) |
Create the positive direction along the given axis. |
This class, along with its sister class CoordinateDirection, provides convenient manipulation of the three coordinate axes via the definition of three constants XAxis, YAxis, and ZAxis each with a unique subtype and implicit conversion to the integers 0, 1, and 2 whenever necessary. Methods are provided to allow code to be written once that can be used to work with the axes in any order.
There are also three CoordinateDirection constants NegXAxis, NegYAxis, and NegZAxis, also with unique types permitting efficient compile time manipulation. These do not correspond to integers, however. Instead, they are objects containing one of the CoordinateAxis objects combined with an integer that is 1 or -1 to indicate the direction along that axis. The unary negation operator is overloaded so that -XAxis is NegXAxis and -NegZAxis is ZAxis. There are implicit conversions to UnitVec3 for any CoordinateAxis or CoordinateDirection object, yielding the equivalent (normalized) unit vector corresponding to any of the six directions, without doing any computation (and in particular, without normalizing).
SimTK::CoordinateAxis::CoordinateAxis | ( | int | i | ) | [inline, explicit] |
Explicit construction of a CoordinateAxis from a calculated integer that must be 0, 1, or 2 representing XAxis, YAxis, or ZAxis.
SimTK::CoordinateAxis::operator int | ( | ) | const [inline] |
Implicit conversion of a CoordinateAxis to int 0, 1, or 2.
CoordinateAxis SimTK::CoordinateAxis::getNextAxis | ( | ) | const [inline] |
Return the "next" coordinate axis after this one:
CoordinateAxis SimTK::CoordinateAxis::getPreviousAxis | ( | ) | const [inline] |
Return the "previous" coordinate axis before this one:
CoordinateAxis SimTK::CoordinateAxis::getThirdAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Given this coordinate axis and one other, return the missing one:
[in] | axis2 | A coordinate axis that must be distinct from the current one; it is a fatal error to provide the same axis. |
bool SimTK::CoordinateAxis::isXAxis | ( | ) | const [inline] |
Return true if this is the X axis.
bool SimTK::CoordinateAxis::isYAxis | ( | ) | const [inline] |
Return true if this is the Y axis.
bool SimTK::CoordinateAxis::isZAxis | ( | ) | const [inline] |
Return true if this is the Z axis.
bool SimTK::CoordinateAxis::isNextAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is the one following this one as would be reported by getNextAxis().
bool SimTK::CoordinateAxis::isPreviousAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is the one preceding this one as would be reported by getPreviousAxis().
bool SimTK::CoordinateAxis::isSameAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is the same as this one. You can use operator==() to perform the same comparison.
bool SimTK::CoordinateAxis::areAllSameAxes | ( | const CoordinateAxis & | axis2, |
const CoordinateAxis & | axis3 | ||
) | const [inline] |
Return true if both axis2 and axis3 are the same as this one.
bool SimTK::CoordinateAxis::isDifferentAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is not the same one as this one. You can use operator!=() to perform the same comparison.
bool SimTK::CoordinateAxis::areAllDifferentAxes | ( | const CoordinateAxis & | axis2, |
const CoordinateAxis & | axis3 | ||
) | const [inline] |
Return true if neither axis2 nor axis3 is the same as this axis nor each other; that is, (this,axis2,axis3) together cover all three axes.
bool SimTK::CoordinateAxis::isForwardCyclical | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is the one following this one in a forward cyclical direction, that is, if axis2 is the one that would be reported by getNextAxis().
bool SimTK::CoordinateAxis::isReverseCyclical | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return true if the given axis2 is the one following this one in a reverse cyclical direction, that is, if axis2 is the one that would be reported by getPreviousAxis().
int SimTK::CoordinateAxis::dotProduct | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Perform a specialized dot product between this axis and axis2; returning one if they are the same axis and zero otherwise, without performing any floating point operations.
int SimTK::CoordinateAxis::crossProductSign | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return the sign that would result from a cross product between this axis and axis2: zero if axis2 is the same as this axis; one if the result would be in the positive direction along the third axis; -1 if it would be in the negative direction.
No floating point computations are performed.
CoordinateAxis SimTK::CoordinateAxis::crossProductAxis | ( | const CoordinateAxis & | axis2 | ) | const [inline] |
Return the coordinate axis along which the cross product of this axis and axis2 would lie: same as this if axis2 is the same as this axis (doesn't matter because the sign would be zero); otherwise, the third axis that is neither this one nor axis2.
But note that the actual result may be along that axis or in the negative direction along that axis. No floating point computations are performed.
CoordinateAxis SimTK::CoordinateAxis::crossProduct | ( | const CoordinateAxis & | axis2, |
int & | sign | ||
) | const [inline] |
Return the axis and sign along that axis that would result from a cross product between this axis and axis2; this combines the functions of both crossProductAxis() and crossProductSign().
Note that if axis2 is the same as this axis we'll just return this as the axis but the sign is zero since the magnitude of the result would be zero. No floating point calculations are performed.
const CoordinateAxis & SimTK::CoordinateAxis::getCoordinateAxis | ( | int | i | ) | [inline, static] |
Return a reference to the CoordinateAxis constant XAxis, YAxis, or ZAxis corresponding to the given integer index which must be 0, 1, or 2.
static bool SimTK::CoordinateAxis::isIndexInRange | ( | int | i | ) | [inline, static] |
Return true if the given integer is suitable as a coordinate axis, meaning it is one of 0, 1, or 2 designating XAxis, YAxis, or ZAxis, respectively.
static void SimTK::CoordinateAxis::assertIndexIsInRange | ( | int | i | ) | [inline, static] |
When in Debug mode, throw an assertion if the given integer is not suited as a coordinate axis, as defined by isIndexInRange().
bool operator== | ( | const CoordinateAxis & | a1, |
const CoordinateAxis & | a2 | ||
) | [related] |
Compare two CoordinateAxis objects.
bool operator!= | ( | const CoordinateAxis & | a1, |
const CoordinateAxis & | a2 | ||
) | [related] |
Compare two CoordinateAxis objects.
const CoordinateDirection::NegXDirection & operator- | ( | const CoordinateAxis::XCoordinateAxis & | ) | [related] |
Create the NegXAxis direction by negating XAxis.
No computation is necessary.
const CoordinateDirection::NegYDirection & operator- | ( | const CoordinateAxis::YCoordinateAxis & | ) | [related] |
Create the NegYAxis direction by negating YAxis.
No computation is necessary.
const CoordinateDirection::NegZDirection & operator- | ( | const CoordinateAxis::ZCoordinateAxis & | ) | [related] |
Create the NegZAxis direction by negating ZAxis.
No computation is necessary.
CoordinateDirection operator- | ( | const CoordinateAxis & | axis | ) | [related] |
Create the negative direction along the given axis.
No computation is necessary.
CoordinateDirection operator+ | ( | const CoordinateAxis & | axis | ) | [related] |
Create the positive direction along the given axis.
No computation is necessary.