Simbody  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimTK::UnitVec< P, S > Class Template Reference

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

#include <UnitVec.h>

+ Inheritance diagram for SimTK::UnitVec< P, S >:

Public Types

typedef Vec< 3, P, S > BaseVec
 
typedef UnitRow< P, S > TransposeType
 
- Public Types inherited from SimTK::Vec< 3, P, S >
enum  
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef P E
 Element type of this Vec. More...
 
typedef CNT< E >::TNeg ENeg
 Negated version of this Vec's element type; ENeg==negator< E >. More...
 
typedef CNT< E >::TWithoutNegator EWithoutNegator
 Element type, stripped of negator<> if it has one. More...
 
typedef CNT< E >::TReal EReal
 Type showing just the real part of an element of this Vec if elements are complex; otherwise just the element type. More...
 
typedef CNT< E >::TImag EImag
 Type showing the imaginary part of an element of this Vec as real, if elements are complex; otherwise a type that can hold a zero of the element type. More...
 
typedef CNT< E >::TComplex EComplex
 Type that elements would have if complex, if E is currently real; otherwise just the element type E. More...
 
typedef CNT< E >::THerm EHerm
 Type of the Hermitian transpose of an element of this Vec. More...
 
typedef CNT< E >::TPosTrans EPosTrans
 Type of a positional transpose of an element of this Vec. More...
 
typedef CNT< E >::TSqHermT ESqHermT
 Type of the expression ~E*E (default vector and matrix square; symmetric). More...
 
typedef CNT< E >::TSqTHerm ESqTHerm
 Type of the expression E*~E ("row square"; symmetric). More...
 
typedef CNT< E >::TSqrt ESqrt
 Type required to hold the result of sqrt(E). More...
 
typedef CNT< E >::TAbs EAbs
 Type required to hold the result of abs(E). More...
 
typedef CNT< E >::TStandard EStandard
 Return type of standardize(E) method; a packed type that can hold the value of an element after eliminating negator and conjugate types. More...
 
typedef CNT< E >::TInvert EInvert
 Packed type that can hold the value returned from invert(E), the inverse type of an element. More...
 
typedef CNT< E >::TNormalize ENormalize
 Packed type that can hold the value returned from normalize(E). More...
 
typedef CNT< E >::Scalar EScalar
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef CNT< E >::ULessScalar EULessScalar
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef CNT< E >::Number ENumber
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef CNT< E >::StdNumber EStdNumber
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef CNT< E >::Precision EPrecision
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef CNT< E >::ScalarNormSq EScalarNormSq
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Vec< M, E, STRIDE > T
 The type of this Vec. More...
 
typedef Vec< M, ENeg, STRIDE > TNeg
 Type this Vec would have if its elements were interpreted as negated. More...
 
typedef Vec< M,
EWithoutNegator, STRIDE > 
TWithoutNegator
 Type of this Vec with negator removed from its element type, if the element is negated. More...
 
typedef Vec< M, EReal, STRIDE
*CNT< E >::RealStrideFactor
TReal
 Type of this Vec cast to show only the real part of its element; this might affect the stride. More...
 
typedef Vec< M, EImag, STRIDE
*CNT< E >::RealStrideFactor
TImag
 Type of this Vec cast to show only the imaginary part of its element; this might affect the stride. More...
 
typedef Vec< M, EComplex, STRIDE > TComplex
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Row< M, EHerm, STRIDE > THerm
 Type of this Vec after casting to its Hermitian transpose; that is, the Vec turns into a Row and each element turns into its Hermitian transpose. More...
 
typedef Row< M, E, STRIDE > TPosTrans
 Type of this Vec after casting to its positional transpose; that is, the Vec turns into a Row but the element type remains unchanged. More...
 
typedef E TElement
 Element type of this Vec. More...
 
typedef E TRow
 Type of a row of this CNT object (for a Vec, just its element type). More...
 
typedef Vec TCol
 Type of a column of this CNT object (for a Vec, the whole thing). More...
 
typedef Vec< M, ESqrt, 1 > TSqrt
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Vec< M, EAbs, 1 > TAbs
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Vec< M, EStandard, 1 > TStandard
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Row< M, EInvert, 1 > TInvert
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef Vec< M, ENormalize, 1 > TNormalize
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef ESqHermT TSqHermT
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef SymMat< M, ESqTHermTSqTHerm
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef EScalar Scalar
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef EULessScalar ULessScalar
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef ENumber Number
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef EStdNumber StdNumber
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef EPrecision Precision
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 
typedef EScalarNormSq ScalarNormSq
 These compile-time constants are required of every Composite Numerical Type (CNT). More...
 

Public Member Functions

 UnitVec ()
 Default constructor initializes to all-NaN even in Release mode so that we maintain the above-promised contract. More...
 
 UnitVec (const UnitVec &u)
 Copy constructor does not require normalization since we know the source is a unit vector. More...
 
template<int S2>
 UnitVec (const UnitVec< P, S2 > &u)
 Automatic conversion from UnitVec with different stride; no computation required. More...
 
 UnitVec (const BaseVec &v)
 Explicit conversion from Vec to UnitVec, requiring expensive normalization. More...
 
template<int S2>
 UnitVec (const Vec< 3, P, S2 > &v)
 Explicit conversion from Vec of any stride to this UnitVec, requiring expensive normalization. More...
 
 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. More...
 
 UnitVec (const CoordinateAxis &axis)
 Implicit conversion from a coordinate axis XAxis, YAxis, or ZAxis to a UnitVec3. Does not require any computation. More...
 
 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. More...
 
 UnitVec (int axis)
 Construct a unit axis vector 100 010 001 given 0,1, or 2; this is not an implicit conversion. More...
 
UnitVecoperator= (const UnitVec &u)
 Copy assignment does not require normalization. More...
 
template<int S2>
UnitVecoperator= (const UnitVec< P, S2 > &u)
 Copy assignment from a UnitVec whose stride differs from this one; no normalization required. More...
 
const BaseVecasVec3 () const
 Return a reference to the underlying Vec3 (no copying here). More...
 
UnitVec< P, 1 > negate () const
 Returns a new unit vector pointing in the opposite direction from this one; does not modify this UnitVec object. More...
 
UnitVec< P, 1 > operator- () const
 Returns a new unit vector pointing in the opposite direction from this one. More...
 
const TransposeTypeoperator~ () const
 Return a const reference to this unit vector re-expressed as a unit row; no computational cost. More...
 
TransposeTypeoperator~ ()
 Return a writable reference to this unit vector re-expressed as a unit row; no computational cost. More...
 
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. More...
 
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. More...
 
UnitVec< P, 1 > abs () const
 Return a new unit vector whose measure numbers are the absolute values of the ones here. More...
 
UnitVec< P, 1 > perp () const
 Return a new unit vector perpendicular to this one but otherwise arbitrary. More...
 
 UnitVec (const BaseVec &v, bool)
 (Advanced) 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. More...
 
template<int S2>
 UnitVec (const Vec< 3, RealP, S2 > &v, bool)
 (Advanced) 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). More...
 
- Public Member Functions inherited from SimTK::Vec< 3, P, S >
ScalarNormSq scalarNormSqr () const
 Scalar norm square is sum( conjugate squares of all underlying scalars ), where conjugate square of scalar s is conj(s)*s. More...
 
TSqrt sqrt () const
 Elementwise square root; that is, the return value has the same length as this Vec but with each element replaced by whatever it thinks its square root is. More...
 
TAbs abs () const
 Elementwise absolute value; that is, the return value has the same dimension as this Vec but with each element replaced by whatever it thinks its absolute value is. More...
 
TStandard standardize () const
 Return a copy of this Vec but with the underlying scalar type converted (if necessary) to one of the C++ standard real or complex floating point types. More...
 
EStandard sum () const
 Sum just adds up all the elements into a single return element that is the same type as this Vec's elements except standardized to use one of the C++ built-in real or complex types as its underlying scalars. More...
 
 Vec ()
 Default construction initializes Vec's elements to NaN when debugging but leaves them uninitialized garbage otherwise, so declarations have zero cost in Release builds. More...
 
 Vec (const Vec &src)
 Copy constructor copies the logically-included elements from the source Vec; gaps due to stride are not accessed in either source or destination. More...
 
 Vec (const Vec< M, E, SS > &src)
 This is an implicit conversion from a Vec of the same length and element type but with a different stride. More...
 
 Vec (const Vec< M, ENeg, SS > &src)
 This is an implicit conversion from a Vec of the same length and negated element type (possibly with a different stride). More...
 
 Vec (const Vec< M, EE, SS > &src)
 Construct a Vec from a Vec of the same length, with any stride. More...
 
 Vec (const E &e)
 Construction from a single value of this Vec's element type assigns that value to each element. More...
 
 Vec (const ENeg &ne)
 Construction from a single value of this Vec's negated element type assigns that value to each element, requiring floating point negation to be performed once to compute the type-E representation of the type negator<E> value provided. More...
 
 Vec (int i)
 Given an int value, turn it into a suitable floating point number, convert that to element type E and then feed that to the above single-element constructor. More...
 
 Vec (const E &e0, const E &e1)
 Construct a Vec<2,E> from two elements of type E, etc. More...
 
 Vec (const E &e0, const E &e1, const E &e2)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7)
 
 Vec (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7, const E &e8)
 
 Vec (const EE *p)
 Construction from a pointer to elements of any type EE assumes we're pointing at a C++ array of EE's of the right length, and that EE is assignment compatible with this Vec's element type E. More...
 
Vecoperator= (const Vec &src)
 Copy assignment operator copies the logically-included elements from the source Vec; gaps due to stride are not accessed in either source or destination. More...
 
Vecoperator= (const EE *p)
 Assignment to a pointer to elements of any type EE assumes we're pointing at a C++ array of EE's of the right length, and that EE is assignment compatible with this Vec's element type E. More...
 
Vecoperator= (const Vec< M, EE, SS > &vv)
 Assignment to a conforming Vec, of any element type and stride, provided that the element types are assignment-compatible. More...
 
Vecoperator= (const EE &e)
 
Vecoperator+= (const Vec< M, EE, SS > &r)
 Add in a conforming Vec, of any element type and stride, provided that the element types are addition-compatible. More...
 
Vecoperator+= (const Vec< M, negator< EE >, SS > &r)
 Add in a conforming Vec, of any negated element type and stride, provided that the element types are addition-compatible. More...
 
Vecoperator+= (const EE &e)
 
Vecoperator-= (const Vec< M, EE, SS > &r)
 Subtract off a conforming Vec, of any element type and stride, provided that the element types are addition-compatible. More...
 
Vecoperator-= (const Vec< M, negator< EE >, SS > &r)
 Subtract off a conforming Vec, of any negated element type and stride, provided that the element types are addition-compatible. More...
 
Vecoperator-= (const EE &e)
 
Vec< M, typename CNT< E >
::template Result< EE >::Add > 
conformingAdd (const Vec< M, EE, SS > &r) const
 Vector addition – use operator+ instead. More...
 
Vec< M, typename CNT< E >
::template Result< EE >::Sub > 
conformingSubtract (const Vec< M, EE, SS > &r) const
 Vector subtraction – use operator- instead. More...
 
Mat< M, M, typename CNT< E >
::template Result< EE >::Mul > 
conformingMultiply (const Row< M, EE, SS > &r) const
 Same as outer product (m = col*row) – use operator* or outer() instead. More...
 
Vec< M, typename CNT< E >
::template Result< EE >::Mul > 
elementwiseMultiply (const Vec< M, EE, SS > &r) const
 Elementwise multiply (Matlab . More...
 
Vec< M, typename CNT< E >
::template Result< EE >::Dvd > 
elementwiseDivide (const Vec< M, EE, SS > &r) const
 Elementwise divide (Matlab . More...
 
const Eoperator[] (int i) const
 Select an element of this Vec and return a const reference to it. More...
 
Eoperator[] (int i)
 Select an element of this Vec and return a writable reference to it. More...
 
const Eoperator() (int i) const
 Same as const operator[] above. More...
 
Eoperator() (int i)
 Same as non-const operator[] above. More...
 
ScalarNormSq normSqr () const
 
CNT< ScalarNormSq >::TSqrt norm () const
 
TNormalize normalize () const
 If the elements of this Vec are scalars, the result is what you get by dividing each element by the norm() calculated above. More...
 
TInvert invert () const
 This method is not supported for Vec objects. More...
 
const Vecoperator+ () const
 Unary plus does nothing. More...
 
const TNegoperator- () const
 Unary minus recasts this Vec to a type that has the opposite interpretation of the sign but is otherwise identical, so no computation or copying is performed here. More...
 
TNegoperator- ()
 Recast to negated type and return a writable reference; writing to this will cause the negated result to be placed in the original Vec. More...
 
const THermoperator~ () const
 The Hermitian transpose operator recasts this Vec to a type that specifies the opposite storage order (row vs. column) then returns a reference, so no computation or copying is performed here. More...
 
THermoperator~ ()
 Recast to Hermitian transposed type and return a writable reference; the effect is that writing to elements of the result affects the transposed element of the original Vec. More...
 
const TNegnegate () const
 Non-operator version of unary negation; just a recast. More...
 
TNegupdNegate ()
 Non-operator version of unary negation; recasts and returns a writable reference. More...
 
const THermtranspose () const
 Non-operator version of Hermitian transpose; just a recast. More...
 
THermupdTranspose ()
 Non-operator version of Hermitian transpose; recasts and returns a writable reference. More...
 
const TPosTranspositionalTranspose () const
 Positional transpose turns this Vec into a Row but does not transpose the individual elements. More...
 
TPosTransupdPositionalTranspose ()
 Positional transpose returning a writable reference. More...
 
const TRealreal () const
 Return a reference to the real portion of this Vec if it has complex elements; otherwise the type doesn't change. More...
 
TRealreal ()
 Recast to show only the real portion of this Vec and return a writable reference. More...
 
const TImagimag () const
 Return a reference to the imaginary portion of this Vec if it has complex elements; otherwise the type doesn't change. More...
 
TImagimag ()
 Recast to show only the imaginary portion of this Vec and return a writable reference. More...
 
const TWithoutNegatorcastAwayNegatorIfAny () const
 Recast to remove negators from this Vec's type if present; this is handy for simplifying operations where we know the sign can be ignored such as squaring. More...
 
TWithoutNegatorupdCastAwayNegatorIfAny ()
 Recast to remove negators from this Vec's type if present and return a writable reference. More...
 
Vec< M, typename CNT< E >
::template Result< EE >::Mul > 
scalarMultiply (const EE &e) const
 
Vec< M, typename CNT< EE >
::template Result< E >::Mul > 
scalarMultiplyFromLeft (const EE &e) const
 
Vec< M, typename CNT< E >
::template Result< EE >::Dvd > 
scalarDivide (const EE &e) const
 
Vec< M, typename CNT< EE >
::template Result< E >::Dvd > 
scalarDivideFromLeft (const EE &e) const
 
Vec< M, typename CNT< E >
::template Result< EE >::Add > 
scalarAdd (const EE &e) const
 
Vec< M, typename CNT< E >
::template Result< EE >::Sub > 
scalarSubtract (const EE &e) const
 
Vec< M, typename CNT< EE >
::template Result< E >::Sub > 
scalarSubtractFromLeft (const EE &e) const
 
Vecoperator*= (const EE &e)
 
Vecoperator/= (const EE &e)
 
VecscalarEq (const EE &ee)
 
VecscalarEq (int ee)
 
VecscalarPlusEq (const EE &ee)
 
VecscalarPlusEq (int ee)
 
VecscalarMinusEq (const EE &ee)
 
VecscalarMinusEq (int ee)
 
VecscalarMinusEqFromLeft (const EE &ee)
 
VecscalarMinusEqFromLeft (int ee)
 
VecscalarTimesEq (const EE &ee)
 
VecscalarTimesEq (int ee)
 
VecscalarTimesEqFromLeft (const EE &ee)
 
VecscalarTimesEqFromLeft (int ee)
 
VecscalarDivideEq (const EE &ee)
 
VecscalarDivideEq (int ee)
 
VecscalarDivideEqFromLeft (const EE &ee)
 
VecscalarDivideEqFromLeft (int ee)
 
void setToNaN ()
 Set every scalar in this Vec to NaN; this is the default initial value in Debug builds, but not in Release. More...
 
void setToZero ()
 Set every scalar in this Vec to zero. More...
 
const Vec< MM, P, STRIDE > & getSubVec (int i) const
 Extract a const reference to a sub-Vec with size known at compile time. More...
 
Vec< MM, P, STRIDE > & updSubVec (int i)
 Extract a writable reference to a sub-Vec with size known at compile time. More...
 
Vec< M-1, P, 1 > drop1 (int p) const
 Return a vector one smaller than this one by dropping the element at the indicated position p. More...
 
Vec< M+1, P, 1 > append1 (const EE &v) const
 Return a vector one larger than this one by adding an element to the end. More...
 
Vec< M+1, P, 1 > insert1 (int p, const EE &v) const
 Return a vector one larger than this one by inserting an element before the indicated one. More...
 
bool isNaN () const
 Return true if any element of this Vec contains a NaN anywhere. More...
 
bool isInf () const
 Return true if any element of this Vec contains a +Infinity or -Infinity somewhere but no element contains a NaN anywhere. More...
 
bool isFinite () const
 Return true if no element of this Vec contains an Infinity or a NaN anywhere. More...
 
bool isNumericallyEqual (const Vec< M, E2, RS2 > &v, double tol) const
 Test whether this vector is numerically equal to some other vector with the same shape, using a specified tolerance. More...
 
bool isNumericallyEqual (const Vec< M, E2, RS2 > &v) const
 Test whether this vector is numerically equal to some other vector with the same shape, using a default tolerance which is the looser of the default tolerances of the two objects being compared. More...
 
bool isNumericallyEqual (const P &e, double tol=getDefaultTolerance()) const
 Test whether every element of this vector is numerically equal to the given element, using either a specified tolerance or the vector's default tolerance (which is always the same or looser than the default tolerance for one of its elements). More...
 
std::string toString () const
 Print Vec into a string and return it. More...
 
void set (int i, const E &value)
 Variant of operator[] that's scripting friendly to set ith entry. More...
 
const Eget (int i) const
 Variant of operator[] that's scripting friendly to get const reference to ith entry. More...
 

Static Public Member Functions

static const UnitVecgetAs (const RealP *p)
 (Advanced) Reinterpret a given memory location as a UnitVec like this one, without checking – don't use this if you aren't absolutely certain that the memory location actually does contain a unit vector, with the correct stride! This overrides the base Vec class method of the same name. More...
 
- Static Public Member Functions inherited from SimTK::Vec< 3, P, S >
static int size ()
 The number of elements in this Vec (note that stride does not affect this number.) More...
 
static int nrow ()
 The number of rows in a Vec is the number of elements. More...
 
static int ncol ()
 The number of columns in a Vec is always 1. More...
 
static const VecgetSubVec (const Vec< MM, P, STRIDE > &v, int i)
 Extract a subvector of type Vec from a longer one that has the same element type and stride, and return a const reference to the selected subsequence. More...
 
static VecupdSubVec (Vec< MM, P, STRIDE > &v, int i)
 Extract a subvector of type Vec from a longer one that has the same element type and stride, and return a writable reference to the selected subsequence. More...
 
static const VecgetAs (const P *p)
 Recast an ordinary C++ array E[] to a const Vec<M,E,S>; assumes compatible length, stride, and packing. More...
 
static VecupdAs (P *p)
 Recast a writable ordinary C++ array E[] to a writable Vec<M,E,S>; assumes compatible length, stride, and packing. More...
 
static Vec< M, P, 1 > getNaN ()
 Return a Vec of the same length and element type as this one but with all elements set to NaN. More...
 
static double getDefaultTolerance ()
 For approximate comparisions, the default tolerance to use for a vector is the same as its elements' default tolerance. More...
 

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

Detailed Description

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

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

  • the length is one (to within a very small tolerance), or
  • all components are NaN.

Member Typedef Documentation

template<class P, int S>
typedef Vec<3,P,S> SimTK::UnitVec< P, S >::BaseVec
template<class P, int S>
typedef UnitRow<P,S> SimTK::UnitVec< P, S >::TransposeType

Constructor & Destructor Documentation

template<class P, int S>
SimTK::UnitVec< P, S >::UnitVec ( )
inline

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

template<class P, int S>
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.

template<class P, int S>
template<int S2>
SimTK::UnitVec< P, S >::UnitVec ( const UnitVec< P, S2 > &  u)
inline

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

template<class P, int S>
SimTK::UnitVec< P, S >::UnitVec ( const BaseVec v)
inlineexplicit

Explicit conversion from Vec to UnitVec, requiring expensive normalization.

template<class P, int S>
template<int S2>
SimTK::UnitVec< P, S >::UnitVec ( const Vec< 3, P, S2 > &  v)
inlineexplicit

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

template<class P, int S>
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.

template<class P, int S>
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.

template<class P, int S>
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.

template<class P, int S>
SimTK::UnitVec< P, S >::UnitVec ( int  axis)
inlineexplicit

Construct a unit axis vector 100 010 001 given 0,1, or 2; this is not an implicit conversion.

template<class P, int S>
SimTK::UnitVec< P, S >::UnitVec ( const BaseVec v,
bool   
)
inline

(Advanced) 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<class P, int S>
template<int S2>
SimTK::UnitVec< P, S >::UnitVec ( const Vec< 3, RealP, S2 > &  v,
bool   
)
inline

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

template<class P, int S>
UnitVec& SimTK::UnitVec< P, S >::operator= ( const UnitVec< P, S > &  u)
inline

Copy assignment does not require normalization.

template<class P, int S>
template<int S2>
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.

template<class P, int S>
const BaseVec& SimTK::UnitVec< P, S >::asVec3 ( ) const
inline

Return a reference to the underlying Vec3 (no copying here).

template<class P, int S>
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.

template<class P, int 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.

template<class P, int 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.

template<class P, int 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.

template<class P, int 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.

template<class P, int 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.

template<class P, int 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.

template<class P , int 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.

template<class P, int S>
static const UnitVec& SimTK::UnitVec< P, S >::getAs ( const RealP *  p)
inlinestatic

(Advanced) Reinterpret a given memory location as a UnitVec like this one, without checking – don't use this if you aren't absolutely certain that the memory location actually does contain a unit vector, with the correct stride! This overrides the base Vec class method of the same name.

Friends And Related Function Documentation

template<class P , int S1, int S2>
bool operator== ( const UnitVec< P, S1 > &  u1,
const UnitVec< P, S2 > &  u2 
)
related

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

Compare two UnitVec3 objects and return true unless they are exactly bitwise equal (not very useful).


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