1 #ifndef SimTK_SimTKCOMMON_COORDINATE_AXIS_H_
2 #define SimTK_SimTKCOMMON_COORDINATE_AXIS_H_
60 operator int()
const {
return m_myAxisId;}
90 bool isXAxis()
const {
return m_myAxisId == 0;}
92 bool isYAxis()
const {
return m_myAxisId == 1;}
94 bool isZAxis()
const {
return m_myAxisId == 2;}
106 {
return m_myAxisId == int(axis2); }
114 {
return m_myAxisId != int(axis2); }
178 class XCoordinateAxis;
class YCoordinateAxis;
class ZCoordinateAxis;
218 return (i==0 ? static_cast<const CoordinateAxis&>(
XAxis)
219 : (i==1 ? static_cast<const CoordinateAxis&>(
YAxis)
220 : static_cast<const CoordinateAxis&>(
ZAxis)));
255 : m_axis(axis), m_direction(1) {}
260 : m_axis(axis), m_direction(-1) {}
270 : m_axis(axis), m_direction(direction)
271 { assert(direction==1 || direction==-1); }
296 {
if (m_axis != dir2.
getAxis())
return 0;
305 {
if (m_axis == dir2.
getAxis())
return 0;
331 class NegXDirection;
class NegYDirection;
class NegZDirection;
414 #endif // SimTK_SimTKCOMMON_COORDINATE_AXIS_H_
const CoordinateDirection::NegZDirection NegZAxis
Global constant indicating -Z coordinate direction.
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:202
NegZDirection()
Definition: CoordinateAxis.h:347
const CoordinateAxis::YCoordinateAxis & operator-(const CoordinateDirection::NegYDirection &)
Create the YAxis direction by negating NegYAxis.
Definition: CoordinateAxis.h:400
CoordinateAxis crossProductAxis(const CoordinateAxis &axis2) const
Return the coordinate axis along which the cross product of this axis and axis2 would lie: same as th...
Definition: CoordinateAxis.h:152
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...
Definition: CoordinateAxis.h:283
int crossProductSign(const CoordinateDirection &dir2) const
Return the sign that would result from a cross product between this coordinate direction and dir2: 0 ...
Definition: CoordinateAxis.h:304
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 ...
Definition: CoordinateAxis.h:143
CoordinateDirection operator-(const CoordinateDirection &dir)
Create the opposite direction from the given direction.
Definition: CoordinateAxis.h:409
const CoordinateDirection::NegXDirection NegXAxis
Global constant indicating -X coordinate direction.
YCoordinateAxis()
Definition: CoordinateAxis.h:200
static const CoordinateAxis & getCoordinateAxis(int i)
Return a reference to the CoordinateAxis constant XAxis, YAxis, or ZAxis corresponding to the given i...
Definition: CoordinateAxis.h:216
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 ...
Definition: CoordinateAxis.h:105
bool operator!=(const CoordinateDirection &d1, const CoordinateDirection &d2)
Compare two CoordinateDirection objects.
Definition: CoordinateAxis.h:364
Definition: CoordinateAxis.h:196
A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direct...
Definition: CoordinateAxis.h:246
Definition: CoordinateAxis.h:199
Definition: CoordinateAxis.h:202
static void assertIndexIsInRange(int i)
When in Debug mode, throw an assertion if the given integer is not suited as a coordinate axis...
Definition: CoordinateAxis.h:175
CoordinateAxis getPreviousAxis() const
Return the "previous" coordinate axis before this one:
Definition: CoordinateAxis.h:73
CoordinateAxis crossProductAxis(const CoordinateDirection &dir2) const
Return the coordinate axis along which the cross product of this coordinate direction and dir2 would ...
Definition: CoordinateAxis.h:316
XCoordinateAxis()
Definition: CoordinateAxis.h:197
const CoordinateAxis::ZCoordinateAxis ZAxis
Constant representing the Z coordinate axis; will implicitly convert to the integer 2 when used in a ...
This class, along with its sister class CoordinateDirection, provides convenient manipulation of the ...
Definition: CoordinateAxis.h:53
CoordinateDirection(const CoordinateAxis &axis, int direction)
Explicit creation of a CoordinateDirection from a CoordinateAxis and a direction calculated at run ti...
Definition: CoordinateAxis.h:269
const CoordinateDirection::NegYDirection NegYAxis
Global constant indicating -Y coordinate direction.
static bool isIndexInRange(int i)
Return true if the given integer is suitable as a coordinate axis, meaning it is one of 0...
Definition: CoordinateAxis.h:172
const CoordinateAxis::YCoordinateAxis YAxis
Constant representing the Y coordinate axis; will implicitly convert to the integer 1 when used in a ...
bool operator==(const CoordinateAxis &a1, const CoordinateAxis &a2)
Compare two CoordinateAxis objects.
Definition: CoordinateAxis.h:224
CoordinateAxis getThirdAxis(const CoordinateAxis &axis2) const
Given this coordinate axis and one other, return the missing one:
Definition: CoordinateAxis.h:83
bool isYAxis() const
Return true if this is the Y axis.
Definition: CoordinateAxis.h:92
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.
Definition: CoordinateAxis.h:276
CoordinateAxis(int i)
Explicit construction of a CoordinateAxis from a calculated integer that must be 0, 1, or 2 representing XAxis, YAxis, or ZAxis.
Definition: CoordinateAxis.h:57
bool isForwardCyclical(const CoordinateAxis &axis2) const
Return true if the given axis2 is the one following this one in a forward cyclical direction...
Definition: CoordinateAxis.h:125
const CoordinateAxis::ZCoordinateAxis & operator-(const CoordinateDirection::NegZDirection &)
Create the ZAxis direction by negating NegZAxis.
Definition: CoordinateAxis.h:404
int dotProduct(const CoordinateDirection &dir2) const
Perform a specialized dot product between this coordinate direction and dir2; returning 1 or -1 if th...
Definition: CoordinateAxis.h:295
CoordinateDirection(const CoordinateAxis &axis)
Implicit conversion of a CoordinateAxis to a positive CoordinateDirection along that axis...
Definition: CoordinateAxis.h:254
bool isPreviousAxis(const CoordinateAxis &axis2) const
Return true if the given axis2 is the one preceding this one as would be reported by getPreviousAxis(...
Definition: CoordinateAxis.h:101
const CoordinateDirection::NegYDirection & operator-(const CoordinateAxis::YCoordinateAxis &)
Create the NegYAxis direction by negating YAxis.
Definition: CoordinateAxis.h:375
Use for compile-time construction of a negative CoordinateDirection along one of the coordinate axes...
Definition: CoordinateAxis.h:250
bool isNextAxis(const CoordinateAxis &axis2) const
Return true if the given axis2 is the one following this one as would be reported by getNextAxis()...
Definition: CoordinateAxis.h:97
CoordinateDirection operator-(const CoordinateAxis &axis)
Create the negative direction along the given axis.
Definition: CoordinateAxis.h:384
bool operator==(const CoordinateDirection &d1, const CoordinateDirection &d2)
Compare two CoordinateDirection objects.
Definition: CoordinateAxis.h:359
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 coordina...
Definition: CoordinateAxis.h:326
CoordinateAxis getNextAxis() const
Return the "next" coordinate axis after this one:
Definition: CoordinateAxis.h:66
bool isXAxis() const
Return true if this is the X axis.
Definition: CoordinateAxis.h:90
Mandatory first inclusion for any Simbody source or header file.
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 t...
Definition: CoordinateAxis.h:113
bool isZAxis() const
Return true if this is the Z axis.
Definition: CoordinateAxis.h:94
ZCoordinateAxis()
Definition: CoordinateAxis.h:203
CoordinateDirection(const CoordinateAxis &axis, Negative)
Explicit creation of a negative CoordinateDirection from a CoordinateAxis.
Definition: CoordinateAxis.h:259
bool isReverseCyclical(const CoordinateAxis &axis2) const
Return true if the given axis2 is the one following this one in a reverse cyclical direction...
Definition: CoordinateAxis.h:130
int getDirection() const
Returns 1 or -1 to indicate the direction along the coordinate axis returned by getAxis().
Definition: CoordinateAxis.h:279
unsigned int sign(unsigned char u)
Definition: Scalar.h:311
const CoordinateAxis::XCoordinateAxis & operator-(const CoordinateDirection::NegXDirection &)
Create the XAxis direction by negating NegXAxis.
Definition: CoordinateAxis.h:396
int dotProduct(const CoordinateAxis &axis2) const
Perform a specialized dot product between this axis and axis2; returning one if they are the same axi...
Definition: CoordinateAxis.h:136
const CoordinateDirection::NegZDirection & operator-(const CoordinateAxis::ZCoordinateAxis &)
Create the NegZAxis direction by negating ZAxis.
Definition: CoordinateAxis.h:379
CoordinateDirection operator+(const CoordinateAxis &axis)
Create the positive direction along the given axis.
Definition: CoordinateAxis.h:390
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 ...
Definition: CoordinateAxis.h:289
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...
Definition: CoordinateAxis.h:118
NegXDirection()
Definition: CoordinateAxis.h:341
const CoordinateDirection::NegXDirection & operator-(const CoordinateAxis::XCoordinateAxis &)
Create the NegXAxis direction by negating XAxis.
Definition: CoordinateAxis.h:371
NegYDirection()
Definition: CoordinateAxis.h:344
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...
Definition: CoordinateAxis.h:162
Definition: CoordinateAxis.h:346
bool operator!=(const CoordinateAxis &a1, const CoordinateAxis &a2)
Compare two CoordinateAxis objects.
Definition: CoordinateAxis.h:228
Definition: CoordinateAxis.h:343
bool areAllSameAxes(const CoordinateAxis &axis2, const CoordinateAxis &axis3) const
Return true if both axis2 and axis3 are the same as this one.
Definition: CoordinateAxis.h:108
Definition: CoordinateAxis.h:340
const CoordinateAxis::XCoordinateAxis XAxis
Constant representing the X coordinate axis; will implicitly convert to the integer 0 when used in a ...