Main Page   Namespace List   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 #ifdef WIN32
00023         #include <fstream>
00024         #include <iostream>
00025         #include <list>
00026         #include <vector>
00027         using namespace std;
00028 #else
00029         #include <stream.h>
00030         #include <list.h>
00031         #include <vector.h>
00032 #endif
00033 
00034 #include "mslio.h"
00035 
00036 void error_handler(int i, const char* s);
00037 
00038 class MSLVector
00039 {
00040   friend class MSLMatrix;
00041 
00042   double* v;
00043   int d;
00044 
00045   void check_dimensions(const MSLVector&) const;
00046  
00047 public:
00048 
00049   MSLVector(); 
00050   MSLVector(int d); 
00051   MSLVector(double a, double b);
00052   MSLVector(double a, double b, double c);
00053   MSLVector(const MSLVector& w, int prec);
00054   MSLVector(const MSLVector&);
00055   ~MSLVector(); 
00056   MSLVector& operator=(const MSLVector&);
00057 
00058   int    dim()    const { return d; }
00059   double& operator[](int i);
00060   double  operator[](int) const;
00061   double  hcoord(int i) const { return (i<d) ? (*this)[i] : 1; }
00062   double  coord(int i)  const { return (*this)[i]; }
00063   double sqr_length() const;
00064   double length() const;
00065   MSLVector norm() const { return *this/length(); }
00066   double angle(const MSLVector& w) const; 
00067   MSLVector rotate90() const;
00068   MSLVector rotate(double a) const;
00069   MSLVector& operator+=(const MSLVector&);
00070   MSLVector& operator-=(const MSLVector&);
00071   MSLVector  operator+(const MSLVector& v1) const;
00072   MSLVector  operator-(const MSLVector& v1) const;
00073   double  operator*(const MSLVector& v1) const;
00074   MSLVector  operator*(double r)        const;
00075   MSLVector  operator-() const;
00076   MSLVector  operator/(double)        const;
00077   bool     operator==(const MSLVector& w) const;
00078   bool     operator!=(const MSLVector& w)  const { return !(*this == w); }
00079   friend MSLVector operator*(double f, const MSLVector& v) { return v *f; }
00080   void print(ostream& O);
00081   void print() { print(cout); }
00082   void read(istream& I);
00083   void read() { read(cin); }
00084   friend ostream& operator<<(ostream& O, const MSLVector& v);
00085   friend istream& operator>>(istream& I, MSLVector& v);
00086 };
00087 
00088 ostream& operator<<(ostream& O, const MSLVector& v);
00089 istream& operator>>(istream& I, MSLVector& v);
00090 
00091 #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.