math/VectorN.h

Go to the documentation of this file.
00001 
00002 #ifndef VectorN_h
00003 #define VectorN_h 1
00004 
00005 #include <vector>
00006 #include "debug/debug.h"
00007 
00008 class VectorN 
00009 {
00010 
00011   public:
00012     //## Constructors (specified)
00013       //## Operation: VectorN%922595691
00014       VectorN ();
00015 
00016       //## Operation: VectorN%922595696
00017       VectorN (const VectorN& right);
00018           explicit VectorN( const double a );
00019           VectorN( const double a, const double b );
00020       VectorN( const double a, const double b, const double c );
00021           VectorN( const double a, const double b, const double c, const double d );
00022 
00023     //## Destructor (generated)
00024       virtual ~VectorN();
00025 
00026 
00027       void SetLength (const int length);
00028 
00029       double&       operator [] (const unsigned int index);
00030       inline const double& operator [] (const unsigned int index) const;
00031 
00032       VectorN& operator =  ( const VectorN& right);
00033       VectorN  operator +  ( const VectorN& right) const;
00034       VectorN  operator -  ( const VectorN& right) const;
00035       VectorN  operator *  ( const double   right) const;
00036           VectorN& operator *= ( const double   right);
00037       VectorN& operator += ( const VectorN& right);
00038       VectorN& operator -= ( const VectorN& right);
00039       VectorN  operator /  ( const double   right) const;
00040       VectorN& operator /= ( const double   right);
00041 
00042       double       Dot( const VectorN& right ) const;
00043       unsigned int Length () const;
00044       unsigned int Size() const { return Length(); }
00045       unsigned int size() const { return Size(); }
00046       virtual void Output () const;
00047 
00048       //## Operation: operator==%930083381
00049       //        Assignment operator for vectors.  Returns a reference to
00050       //        the resultant.
00051       bool operator == (const VectorN& right) const;
00052 
00053       //## Operation: operator!=%930083382
00054       //        Assignment operator for vectors.  Returns a reference to
00055       //        the resultant.
00056       bool operator != (const VectorN& right) const;
00057 
00058           // Compares if two vectors are equal to within a given Tolerance.
00059           bool Compare( const VectorN& right, const double& tol) const;
00060       void Append( const VectorN& right );
00061       void Normalize();
00062       double MagSquared () const;
00063       double Magnitude () const;
00064       void clear();
00065       void push_back( const double newElement );
00066       void reserve( const unsigned int size );
00067       void resize( const unsigned int size, const double fill = 0.0 );
00068   protected:
00069   private:
00070       std::vector< double > elements;
00071 };
00072 
00073 double  Average( const VectorN& v );
00074 VectorN ClosestPoint   ( const VectorN& c0, const VectorN& c1, const VectorN& p );
00075 double  DistanceSquared( const VectorN& c0, const VectorN& c1, const VectorN& p );
00076 VectorN Ln( const VectorN& right );
00077 VectorN operator*( const double f, const VectorN& v );
00078 std::ostream& operator<<( std::ostream &os, const VectorN& v ) ;
00079 std::istream& operator>>( std::istream &is, VectorN& v ) ;
00080 
00081 //=============================================================================
00082 // VectorN::operator[]
00083 //=============================================================================
00084 const double& VectorN::operator[] ( const unsigned int index ) const
00085 {
00086     #ifdef _DEBUG
00087             int size = elements.size();
00088             IJG_Assert( size > index );
00089     #endif
00090         return elements[ index ];
00091 }
00092 
00093 #endif

Generated on Sat Apr 1 21:30:39 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO