Simbody  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimTK::CoordinateAxis Class Reference

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>

+ Inheritance diagram for SimTK::CoordinateAxis:

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. More...
 
 operator int () const
 Implicit conversion of a CoordinateAxis to int 0, 1, or 2. More...
 
CoordinateAxis getNextAxis () const
 Return the "next" coordinate axis after this one: More...
 
CoordinateAxis getPreviousAxis () const
 Return the "previous" coordinate axis before this one: More...
 
CoordinateAxis getThirdAxis (const CoordinateAxis &axis2) const
 Given this coordinate axis and one other, return the missing one: More...
 
bool isXAxis () const
 Return true if this is the X axis. More...
 
bool isYAxis () const
 Return true if this is the Y axis. More...
 
bool isZAxis () const
 Return true if this is the Z axis. More...
 
bool isNextAxis (const CoordinateAxis &axis2) const
 Return true if the given axis2 is the one following this one as would be reported by getNextAxis(). More...
 
bool isPreviousAxis (const CoordinateAxis &axis2) const
 Return true if the given axis2 is the one preceding this one as would be reported by getPreviousAxis(). More...
 
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. More...
 
bool areAllSameAxes (const CoordinateAxis &axis2, const CoordinateAxis &axis3) const
 Return true if both axis2 and axis3 are the same as this one. More...
 
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. More...
 
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. More...
 
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(). More...
 
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(). More...
 
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. More...
 
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. More...
 
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. More...
 
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(). More...
 

Static Public Member Functions

static const CoordinateAxisgetCoordinateAxis (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. More...
 
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. More...
 
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(). More...
 

Related Functions

(Note that these are not member functions.)

bool operator== (const CoordinateAxis &a1, const CoordinateAxis &a2)
 Compare two CoordinateAxis objects. More...
 
bool operator!= (const CoordinateAxis &a1, const CoordinateAxis &a2)
 Compare two CoordinateAxis objects. More...
 
const
CoordinateDirection::NegXDirection
operator- (const CoordinateAxis::XCoordinateAxis &)
 Create the NegXAxis direction by negating XAxis. More...
 
const
CoordinateDirection::NegYDirection
operator- (const CoordinateAxis::YCoordinateAxis &)
 Create the NegYAxis direction by negating YAxis. More...
 
const
CoordinateDirection::NegZDirection
operator- (const CoordinateAxis::ZCoordinateAxis &)
 Create the NegZAxis direction by negating ZAxis. More...
 
CoordinateDirection operator- (const CoordinateAxis &axis)
 Create the negative direction along the given axis. More...
 
CoordinateDirection operator+ (const CoordinateAxis &axis)
 Create the positive direction along the given axis. More...
 

Detailed Description

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

See Also
CoordinateDirection

Constructor & Destructor Documentation

SimTK::CoordinateAxis::CoordinateAxis ( int  i)
inlineexplicit

Explicit construction of a CoordinateAxis from a calculated integer that must be 0, 1, or 2 representing XAxis, YAxis, or ZAxis.

Member Function Documentation

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:

  • XAxis.getNextAxis() returns YAxis
  • YAxis.getNextAxis() returns ZAxis
  • ZAxis.getNextAxis() returns XAxis
CoordinateAxis SimTK::CoordinateAxis::getPreviousAxis ( ) const
inline

Return the "previous" coordinate axis before this one:

  • XAxis.getPreviousAxis() returns ZAxis
  • YAxis.getPreviousAxis() returns XAxis
  • ZAxis.getPreviousAxis() returns YAxis
CoordinateAxis SimTK::CoordinateAxis::getThirdAxis ( const CoordinateAxis axis2) const
inline

Given this coordinate axis and one other, return the missing one:

  • XAxis.getThirdAxis(YAxis) returns ZAxis (and vice versa)
  • XAxis.getThirdAxis(ZAxis) returns YAxis (and vice versa)
  • YAxis.getThirdAxis(ZAxis) returns XAxis (and vice versa)
    Parameters
    [in]axis2A coordinate axis that must be distinct from the current one; it is a fatal error to provide the same axis.
    Returns
    The unmentioned third 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.

See Also
crossProductAxis()
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.

See Also
crossProductSign().
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.

See Also
crossProductSign(), crossProductAxis()
const CoordinateAxis & SimTK::CoordinateAxis::getCoordinateAxis ( int  i)
inlinestatic

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

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

When in Debug mode, throw an assertion if the given integer is not suited as a coordinate axis, as defined by isIndexInRange().

Friends And Related Function Documentation

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.

Create the NegXAxis direction by negating XAxis.

No computation is necessary.

Create the NegYAxis direction by negating YAxis.

No computation is necessary.

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.


The documentation for this class was generated from the following file: