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 (int axis) | |
Construct a unit axis vector 100 010 001 given 0,1, or 2. | |
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). |
This class is a Vec3 plus an ironclad guarantee either that:
typedef UnitRow<P,S> TransposeType |
UnitVec | ( | ) | [inline] |
Default constructor initializes to all-NaN even in Release mode so that we maintain the above-promised contract.
Copy constructor does not require normalization since we know the source is a unit vector.
Automatic conversion from UnitVec with different stride; no computation required.
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.
UnitVec | ( | int | axis | ) | [inline, explicit] |
Construct a unit axis vector 100 010 001 given 0,1, or 2.
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 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<P,1> 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 Vec< 3, P, S >.
Referenced by UnitVec< P, S >::perp().
const BaseVec& asVec3 | ( | ) | const [inline] |
Return a reference to the underlying Vec3 (no copying here).
Referenced by UnitVec< Real, 1 >::abs(), UnitVec< Real, 1 >::negate(), SimTK::operator*(), Rotation_< Real >::setRotationColFromUnitVecTrustMe(), and Rotation_< Real >::setRotationFromUnitVecsTrustMe().
UnitVec<P,1> 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 Vec< 3, P, S >.
Referenced by UnitVec< Real, 1 >::operator-().
const RealP& 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 Vec< 3, P, S >.
UnitVec<P,1> operator- | ( | ) | const [inline] |
Returns a new unit vector pointing in the opposite direction from this one.
Cost is 3 flops.
Reimplemented from Vec< 3, P, S >.
Copy assignment from a UnitVec whose stride differs from this one; no normalization required.
Copy assignment does not require normalization.
const RealP& 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 Vec< 3, P, S >.
TransposeType& operator~ | ( | ) | [inline] |
Return a writable reference to this unit vector re-expressed as a unit row; no computational cost.
Reimplemented from Vec< 3, P, S >.
const TransposeType& operator~ | ( | ) | const [inline] |
Return a const reference to this unit vector re-expressed as a unit row; no computational cost.
Reimplemented from Vec< 3, P, S >.
UnitVec< P, 1 > 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.
References UnitVec< P, S >::abs().