UnitVec< P, S > Class Template Reference

This class is a Vec3 plus an ironclad guarantee either that:

More...

#include <UnitVec.h>

Inheritance diagram for UnitVec< P, S >:
Vec< 3, P, S >

List of all members.

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.
UnitVecoperator= (const UnitVec &u)
 Copy assignment does not require normalization.
template<int S2>
UnitVecoperator= (const UnitVec< P, S2 > &u)
 Copy assignment from a UnitVec whose stride differs from this one; no normalization required.
const BaseVecasVec3 () 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 TransposeTypeoperator~ () const
 Return a const reference to this unit vector re-expressed as a unit row; no computational cost.
TransposeTypeoperator~ ()
 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).

Detailed Description

template<class P, int S>
class SimTK::UnitVec< P, S >

This class is a Vec3 plus an ironclad guarantee either that:


Member Typedef Documentation

typedef Vec<3,P,S> BaseVec
typedef UnitRow<P,S> TransposeType

Constructor & Destructor Documentation

UnitVec (  )  [inline]

Default constructor initializes to all-NaN even in Release mode so that we maintain the above-promised contract.

UnitVec ( const UnitVec< P, S > &  u  )  [inline]

Copy constructor does not require normalization since we know the source is a unit vector.

UnitVec ( const UnitVec< P, S2 > &  u  )  [inline]

Automatic conversion from UnitVec with different stride; no computation required.

UnitVec ( const BaseVec v  )  [inline, explicit]

Explicit conversion from Vec to UnitVec, requiring expensive normalization.

UnitVec ( const Vec< 3, P, S2 > &  v  )  [inline, explicit]

Explicit conversion from Vec of any stride to this UnitVec, requiring expensive normalization.

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.

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.

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


Member Function Documentation

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

UnitVec& operator= ( const UnitVec< P, S2 > &  u  )  [inline]

Copy assignment from a UnitVec whose stride differs from this one; no normalization required.

UnitVec& operator= ( const UnitVec< P, S > &  u  )  [inline]

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


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

Generated on Thu Aug 12 16:38:32 2010 for SimTKcore by  doxygen 1.6.1