Simbody  3.7
SimTK::CoordinateDirection Class Reference

A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direction along that axis. More...

+ Inheritance diagram for SimTK::CoordinateDirection:

Classes

class  Negative
 Use for compile-time construction of a negative CoordinateDirection along one of the coordinate axes. More...
 
class  NegXDirection
 
class  NegYDirection
 
class  NegZDirection
 

Public Member Functions

 CoordinateDirection (const CoordinateAxis &axis)
 Implicit conversion of a CoordinateAxis to a positive CoordinateDirection along that axis. More...
 
 CoordinateDirection (const CoordinateAxis &axis, Negative)
 Explicit creation of a negative CoordinateDirection from a CoordinateAxis. More...
 
 CoordinateDirection (const CoordinateAxis &axis, int direction)
 Explicit creation of a CoordinateDirection from a CoordinateAxis and a direction calculated at run time. More...
 
CoordinateAxis getAxis () const
 This is the coordinate axis XAxis, YAxis, or ZAxis contained in this CoordinateDirection. Use getDirection() to determine whether this is the positive or negative direction. More...
 
int getDirection () const
 Returns 1 or -1 to indicate the direction along the coordinate axis returned by getAxis(). More...
 
bool hasSameAxis (const CoordinateDirection &dir2) const
 Return true if this direction and dir2 are along the same axis, even if the direction along that axis is not the same. More...
 
bool isSameAxisAndDirection (const CoordinateDirection &dir2) const
 Return true if this direction and dir2 are along the same axis, and in the same direction along that axis. You can also use operator==() for this comparison. More...
 
int dotProduct (const CoordinateDirection &dir2) const
 Perform a specialized dot product between this coordinate direction and dir2; returning 1 or -1 if they contain the same axis and 0 otherwise, without performing any floating point operations. More...
 
int crossProductSign (const CoordinateDirection &dir2) const
 Return the sign that would result from a cross product between this coordinate direction and dir2: 0 if they are along the same axis; 1 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 CoordinateDirection &dir2) const
 Return the coordinate axis along which the cross product of this coordinate direction and dir2 would lie: same as this if both contain the same axis (doesn't matter because the sign would be zero); otherwise, the third axis that neither this one nor dir2 contains. More...
 
CoordinateAxis crossProduct (const CoordinateDirection &dir2, int &sign) const
 Return the axis and sign along that axis that would result from a cross product between this coordinate direction and dir2; this combines the functions of both crossProductAxis() and crossProductSign(). More...
 

Related Functions

(Note that these are not member functions.)

bool operator== (const CoordinateDirection &d1, const CoordinateDirection &d2)
 Compare two CoordinateDirection objects. More...
 
bool operator!= (const CoordinateDirection &d1, const CoordinateDirection &d2)
 Compare two CoordinateDirection objects. More...
 
const CoordinateAxis::XCoordinateAxisoperator- (const CoordinateDirection::NegXDirection &)
 Create the XAxis direction by negating NegXAxis. More...
 
const CoordinateAxis::YCoordinateAxisoperator- (const CoordinateDirection::NegYDirection &)
 Create the YAxis direction by negating NegYAxis. More...
 
const CoordinateAxis::ZCoordinateAxisoperator- (const CoordinateDirection::NegZDirection &)
 Create the ZAxis direction by negating NegZAxis. More...
 
CoordinateDirection operator- (const CoordinateDirection &dir)
 Create the opposite direction from the given direction. More...
 

Detailed Description

A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direction along that axis.

There are only six possible values for a CoordinateDirection, and there are predefined constants available covering all of them:

  • XAxis, YAxis, ZAxis are the CoordinateAxis types; they will implicitly convert to positive axis directions.
  • NegXAxis, NegYAxis, NegZAxis are the negative directions.
  • The unary negation operator is overloaded so that -XAxis produces NegXAxis and -NegYAxis produces YAxis.
  • The unary plus operator is overloaded for the CoordinateAxis objects so that +XAxis and so on are the positive CoordinateDirection objects. You can also produce CoordinateDirections at compile time or run time from calculated axes and directions.
    See also
    CoordinateAxis

Constructor & Destructor Documentation

◆ CoordinateDirection() [1/3]

SimTK::CoordinateDirection::CoordinateDirection ( const CoordinateAxis axis)
inline

Implicit conversion of a CoordinateAxis to a positive CoordinateDirection along that axis.

◆ CoordinateDirection() [2/3]

SimTK::CoordinateDirection::CoordinateDirection ( const CoordinateAxis axis,
Negative   
)
inline

Explicit creation of a negative CoordinateDirection from a CoordinateAxis.

◆ CoordinateDirection() [3/3]

SimTK::CoordinateDirection::CoordinateDirection ( const CoordinateAxis axis,
int  direction 
)
inline

Explicit creation of a CoordinateDirection from a CoordinateAxis and a direction calculated at run time.

Parameters
[in]axisXAxis, YAxis, or ZAxis
[in]directionMust be -1 or 1.
Note
Zero is not allowed for direction, meaning that you must not try to produce one of these from the "sign" result of one of the cross product methods, because there the sign can be -1, 0, or 1.

Member Function Documentation

◆ getAxis()

CoordinateAxis SimTK::CoordinateDirection::getAxis ( ) const
inline

This is the coordinate axis XAxis, YAxis, or ZAxis contained in this CoordinateDirection. Use getDirection() to determine whether this is the positive or negative direction.

◆ getDirection()

int SimTK::CoordinateDirection::getDirection ( ) const
inline

Returns 1 or -1 to indicate the direction along the coordinate axis returned by getAxis().

◆ hasSameAxis()

bool SimTK::CoordinateDirection::hasSameAxis ( const CoordinateDirection dir2) const
inline

Return true if this direction and dir2 are along the same axis, even if the direction along that axis is not the same.

◆ isSameAxisAndDirection()

bool SimTK::CoordinateDirection::isSameAxisAndDirection ( const CoordinateDirection dir2) const
inline

Return true if this direction and dir2 are along the same axis, and in the same direction along that axis. You can also use operator==() for this comparison.

◆ dotProduct()

int SimTK::CoordinateDirection::dotProduct ( const CoordinateDirection dir2) const
inline

Perform a specialized dot product between this coordinate direction and dir2; returning 1 or -1 if they contain the same axis and 0 otherwise, without performing any floating point operations.

◆ crossProductSign()

int SimTK::CoordinateDirection::crossProductSign ( const CoordinateDirection dir2) const
inline

Return the sign that would result from a cross product between this coordinate direction and dir2: 0 if they are along the same axis; 1 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()

◆ crossProductAxis()

CoordinateAxis SimTK::CoordinateDirection::crossProductAxis ( const CoordinateDirection dir2) const
inline

Return the coordinate axis along which the cross product of this coordinate direction and dir2 would lie: same as this if both contain the same axis (doesn't matter because the sign would be zero); otherwise, the third axis that neither this one nor dir2 contains.

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

◆ crossProduct()

CoordinateAxis SimTK::CoordinateDirection::crossProduct ( const CoordinateDirection dir2,
int &  sign 
) const
inline

Return the axis and sign along that axis that would result from a cross product between this coordinate direction and dir2; this combines the functions of both crossProductAxis() and crossProductSign().

Note that if dir2 is along the same axis as this one, 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()

Friends And Related Function Documentation

◆ operator==()

bool operator== ( const CoordinateDirection d1,
const CoordinateDirection d2 
)
related

Compare two CoordinateDirection objects.

◆ operator!=()

bool operator!= ( const CoordinateDirection d1,
const CoordinateDirection d2 
)
related

Compare two CoordinateDirection objects.

◆ operator-() [1/4]

Create the XAxis direction by negating NegXAxis.

No computation is necessary.

◆ operator-() [2/4]

Create the YAxis direction by negating NegYAxis.

No computation is necessary.

◆ operator-() [3/4]

Create the ZAxis direction by negating NegZAxis.

No computation is necessary.

◆ operator-() [4/4]

CoordinateDirection operator- ( const CoordinateDirection dir)
related

Create the opposite direction from the given direction.

No computation is necessary.


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