Simbody
|
This class is a Vec3 plus an ironclad guarantee either that:
#include <UnitVec.h>
Public Types | |
typedef Vec< 3, P, S > | BaseVec |
typedef UnitRow< P, S > | TransposeType |
Public Member Functions | |
UnitVec () | |
Default constructor initializes to all-NaN even in Release mode so that we maintain the above-promised contract. | |
UnitVec (const UnitVec &u) | |
Copy constructor does not require normalization since we know the source is a unit vector. | |
template<int S2> | |
UnitVec (const UnitVec< P, S2 > &u) | |
Automatic conversion from UnitVec with different stride; no computation required. | |
UnitVec (const BaseVec &v) | |
Explicit conversion from Vec to UnitVec, requiring expensive normalization. | |
template<int S2> | |
UnitVec (const Vec< 3, P, S2 > &v) | |
Explicit conversion from Vec of any stride to this UnitVec, requiring expensive normalization. | |
UnitVec (const RealP &x, const RealP &y, const RealP &z) | |
Create a unit vector in the direction of the vector (x,y,z) whose measure numbers are supplied -- this requires an expensive normalization since we don't know that the supplied vector is normalized. | |
UnitVec (const CoordinateAxis &axis) | |
Implicit conversion from a coordinate axis XAxis, YAxis, or ZAxis to a UnitVec3. Does not require any computation. | |
UnitVec (const CoordinateDirection &dir) | |
Implicit conversion from a coordinate axis direction to a UnitVec3. The axis direction is given by one of XAxis, YAxis, ZAxis or NegXAxis, NegYAxis, NegZAxis. Does not require any computation. | |
UnitVec (int axis) | |
Construct a unit axis vector 100 010 001 given 0,1, or 2; this is not an implicit conversion. | |
UnitVec & | operator= (const UnitVec &u) |
Copy assignment does not require normalization. | |
template<int S2> | |
UnitVec & | operator= (const UnitVec< P, S2 > &u) |
Copy assignment from a UnitVec whose stride differs from this one; no normalization required. | |
const BaseVec & | asVec3 () const |
Return a reference to the underlying Vec3 (no copying here). | |
UnitVec< P, 1 > | negate () const |
Returns a new unit vector pointing in the opposite direction from this one; does not modify this UnitVec object. | |
UnitVec< P, 1 > | operator- () const |
Returns a new unit vector pointing in the opposite direction from this one. | |
const TransposeType & | operator~ () const |
Return a const reference to this unit vector re-expressed as a unit row; no computational cost. | |
TransposeType & | operator~ () |
Return a writable reference to this unit vector re-expressed as a unit row; no computational cost. | |
const RealP & | operator[] (int i) const |
Return one element of this unit vector as a const reference; there is no corresponding writable index function since changing a single element of a unit vector would violate the contract that it has unit length at all times. | |
const RealP & | operator() (int i) const |
Return one element of this unit vector as a const reference; there is no corresponding writable index function since changing a single element of a unit vector would violate the contract that it has unit length at all times. | |
UnitVec< P, 1 > | abs () const |
Return a new unit vector whose measure numbers are the absolute values of the ones here. | |
UnitVec< P, 1 > | perp () const |
Return a new unit vector perpendicular to this one but otherwise arbitrary. | |
UnitVec (const BaseVec &v, bool) | |
This constructor is only for our friends whom we trust to give us an already-normalized vector which we simply accept as normalized without checking. | |
template<int S2> | |
UnitVec (const Vec< 3, RealP, S2 > &v, bool) | |
This constructor is only for our friends whom we trust to give us an already-normalized vector which we simply accept as normalized without checking (this version accepts an input vector of any stride). | |
Related Functions | |
(Note that these are not member functions.) | |
template<class P , int S1, int S2> | |
bool | operator== (const UnitVec< P, S1 > &u1, const UnitVec< P, S2 > &u2) |
Compare two UnitVec3 objects for exact, bitwise equality (not very useful). | |
template<class P , int S1, int S2> | |
bool | operator!= (const UnitVec< P, S1 > &u1, const UnitVec< P, S2 > &u2) |
Compare two UnitVec3 objects and return true unless they are exactly bitwise equal (not very useful). |
This class is a Vec3 plus an ironclad guarantee either that:
typedef Vec<3,P,S> SimTK::UnitVec< P, S >::BaseVec |
typedef UnitRow<P,S> SimTK::UnitVec< P, S >::TransposeType |
SimTK::UnitVec< P, S >::UnitVec | ( | ) | [inline] |
Default constructor initializes to all-NaN even in Release mode so that we maintain the above-promised contract.
SimTK::UnitVec< P, S >::UnitVec | ( | const UnitVec< P, S > & | u | ) | [inline] |
Copy constructor does not require normalization since we know the source is a unit vector.
SimTK::UnitVec< P, S >::UnitVec | ( | const UnitVec< P, S2 > & | u | ) | [inline] |
Automatic conversion from UnitVec with different stride; no computation required.
SimTK::UnitVec< P, S >::UnitVec | ( | const BaseVec & | v | ) | [inline, explicit] |
SimTK::UnitVec< P, S >::UnitVec | ( | const Vec< 3, P, S2 > & | v | ) | [inline, explicit] |
SimTK::UnitVec< P, S >::UnitVec | ( | const RealP & | x, |
const RealP & | y, | ||
const RealP & | z | ||
) | [inline] |
Create a unit vector in the direction of the vector (x,y,z) whose measure numbers are supplied -- this requires an expensive normalization since we don't know that the supplied vector is normalized.
SimTK::UnitVec< P, S >::UnitVec | ( | const CoordinateAxis & | axis | ) | [inline] |
Implicit conversion from a coordinate axis XAxis, YAxis, or ZAxis to a UnitVec3. Does not require any computation.
SimTK::UnitVec< P, S >::UnitVec | ( | const CoordinateDirection & | dir | ) | [inline] |
Implicit conversion from a coordinate axis direction to a UnitVec3. The axis direction is given by one of XAxis, YAxis, ZAxis or NegXAxis, NegYAxis, NegZAxis. Does not require any computation.
SimTK::UnitVec< P, S >::UnitVec | ( | int | axis | ) | [inline, explicit] |
Construct a unit axis vector 100 010 001 given 0,1, or 2; this is not an implicit conversion.
SimTK::UnitVec< P, S >::UnitVec | ( | const BaseVec & | v, |
bool | |||
) | [inline] |
This constructor is only for our friends whom we trust to give us an already-normalized vector which we simply accept as normalized without checking.
SimTK::UnitVec< P, S >::UnitVec | ( | const Vec< 3, RealP, S2 > & | v, |
bool | |||
) | [inline] |
This constructor is only for our friends whom we trust to give us an already-normalized vector which we simply accept as normalized without checking (this version accepts an input vector of any stride).
UnitVec& SimTK::UnitVec< P, S >::operator= | ( | const UnitVec< P, S > & | u | ) | [inline] |
Copy assignment does not require normalization.
UnitVec& SimTK::UnitVec< P, S >::operator= | ( | const UnitVec< P, S2 > & | u | ) | [inline] |
Copy assignment from a UnitVec whose stride differs from this one; no normalization required.
const BaseVec& SimTK::UnitVec< P, S >::asVec3 | ( | ) | const [inline] |
Return a reference to the underlying Vec3 (no copying here).
UnitVec<P,1> SimTK::UnitVec< P, S >::negate | ( | ) | const [inline] |
Returns a new unit vector pointing in the opposite direction from this one; does not modify this UnitVec object.
Cost is 3 flops.
Reimplemented from SimTK::Vec< 3, P, S >.
UnitVec<P,1> SimTK::UnitVec< P, S >::operator- | ( | ) | const [inline] |
Returns a new unit vector pointing in the opposite direction from this one.
Cost is 3 flops.
Reimplemented from SimTK::Vec< 3, P, S >.
const TransposeType& SimTK::UnitVec< P, S >::operator~ | ( | ) | const [inline] |
Return a const reference to this unit vector re-expressed as a unit row; no computational cost.
Reimplemented from SimTK::Vec< 3, P, S >.
TransposeType& SimTK::UnitVec< P, S >::operator~ | ( | ) | [inline] |
Return a writable reference to this unit vector re-expressed as a unit row; no computational cost.
Reimplemented from SimTK::Vec< 3, P, S >.
const RealP& SimTK::UnitVec< P, S >::operator[] | ( | int | i | ) | const [inline] |
Return one element of this unit vector as a const reference; there is no corresponding writable index function since changing a single element of a unit vector would violate the contract that it has unit length at all times.
Reimplemented from SimTK::Vec< 3, P, S >.
const RealP& SimTK::UnitVec< P, S >::operator() | ( | int | i | ) | const [inline] |
Return one element of this unit vector as a const reference; there is no corresponding writable index function since changing a single element of a unit vector would violate the contract that it has unit length at all times.
Reimplemented from SimTK::Vec< 3, P, S >.
UnitVec<P,1> SimTK::UnitVec< P, S >::abs | ( | ) | const [inline] |
Return a new unit vector whose measure numbers are the absolute values of the ones here.
This will still have unit length but will be a reflection of this unit vector into the first octant (+x,+y,+z). Note that we are returning the packed form of UnitVec regardless of our stride here.
Reimplemented from SimTK::Vec< 3, P, S >.
UnitVec< P, 1 > SimTK::UnitVec< P, S >::perp | ( | ) | const [inline] |
Return a new unit vector perpendicular to this one but otherwise arbitrary.
Some care is taken to ensure good numerical conditioning for the result regardless of what goes in. Cost is about 50 flops.
bool operator== | ( | const UnitVec< P, S1 > & | u1, |
const UnitVec< P, S2 > & | u2 | ||
) | [related] |
Compare two UnitVec3 objects for exact, bitwise equality (not very useful).
bool operator!= | ( | const UnitVec< P, S1 > & | u1, |
const UnitVec< P, S2 > & | u2 | ||
) | [related] |
Compare two UnitVec3 objects and return true unless they are exactly bitwise equal (not very useful).