Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

vector.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //               The Motion Strategy Library (MSL)
00003 //----------------------------------------------------------------------
00004 //
00005 // Copyright (c) University of Illinois and Steven M. LaValle.     
00006 // All Rights Reserved.
00007 //
00008 // Permission to use, copy, and distribute this software and its
00009 // documentation is hereby granted free of charge, provided that
00010 // (1) it is not a component of a commercial product, and
00011 // (2) this notice appears in all copies of the software and
00012 //     related documentation.
00013 //
00014 // The University of Illinois and the author make no representations
00015 // about the suitability or fitness of this software for any purpose.
00016 // It is provided "as is" without express or implied warranty.
00017 //----------------------------------------------------------------------
00018 
00019 #ifndef MSL_VECTOR_H
00020 #define MSL_VECTOR_H
00021 
00022 #include <stream.h>
00023 #include <list.h>
00024 #include <vector.h>
00025 
00026 void error_handler(int i, const char* s);
00027 
00028 class MSLVector
00029 {
00030   friend class MSLMatrix;
00031 
00032   double* v;
00033   int d;
00034 
00035   void check_dimensions(const MSLVector&) const;
00036  
00037 public:
00038 
00039   MSLVector(); 
00040   MSLVector(int d); 
00041   MSLVector(double a, double b);
00042   MSLVector(double a, double b, double c);
00043   MSLVector(const MSLVector& w, int prec);
00044   MSLVector(const MSLVector&);
00045   ~MSLVector(); 
00046   MSLVector& operator=(const MSLVector&);
00047 
00048   int    dim()    const { return d; }
00049   double& operator[](int i);
00050   double  operator[](int) const;
00051   double  hcoord(int i) const { return (i<d) ? (*this)[i] : 1; }
00052   double  coord(int i)  const { return (*this)[i]; }
00053   double sqr_length() const;
00054   double length() const;
00055   MSLVector norm() const { return *this/length(); }
00056   double angle(const MSLVector& w) const; 
00057   MSLVector rotate90() const;
00058   MSLVector rotate(double a) const;
00059   MSLVector& operator+=(const MSLVector&);
00060   MSLVector& operator-=(const MSLVector&);
00061   MSLVector  operator+(const MSLVector& v1) const;
00062   MSLVector  operator-(const MSLVector& v1) const;
00063   double  operator*(const MSLVector& v1) const;
00064   MSLVector  operator*(double r)        const;
00065   MSLVector  operator-() const;
00066   MSLVector  operator/(double)        const;
00067   bool     operator==(const MSLVector& w) const;
00068   bool     operator!=(const MSLVector& w)  const { return !(*this == w); }
00069   friend MSLVector operator*(double f, const MSLVector& v) { return v *f; }
00070   void print(ostream& O);
00071   void print() { print(cout); }
00072   void read(istream& I);
00073   void read() { read(cin); }
00074   friend ostream& operator<<(ostream& O, const MSLVector& v);
00075   friend istream& operator>>(istream& I, MSLVector& v);
00076   friend istream& operator>>(istream& is, list<MSLVector> & vl);
00077   friend ostream& operator<<(ostream& os, const list<MSLVector> & vl);
00078   friend istream& operator>>(istream& is, vector<MSLVector> & vl);
00079   friend ostream& operator<<(ostream& os, const vector<MSLVector> & vl);
00080 };
00081 
00082 
00083 #endif
Motion Strategy Library


Web page maintained by Steve LaValle
Partial support provided by NSF CAREER Award IRI-970228 (LaValle), Honda Research.
Contributors: Anna Atramentov, Peng Cheng, James Kuffner, Steve LaValle, and Libo Yang.