00001 // coord.h 00002 00003 #ifndef COORD_H 00004 #define COORD_H 00005 00006 #include "vr.h" 00007 00011 class Coord 00012 { 00013 public: 00015 double x; 00017 double y; 00019 double z; 00020 00021 public: 00023 Coord(); 00029 Coord(double x, double y = 0.0, double z = 0.0); 00033 Coord(VRSFVec3f coord); 00039 void setCoords(double x = 0.0, double y = 0.0, double z = 0.0); 00040 00045 Coord& operator +=(const Coord &coord); 00050 Coord& operator -=(const Coord &coord); 00055 Coord operator +(const Coord &coord) const; 00060 Coord operator -(const Coord &coord) const; 00064 Coord operator -() const; 00070 Coord& operator =(const Coord &coord); 00076 bool operator ==(const Coord &coord) const; 00077 00082 Coord& operator *=(double d); 00087 Coord& operator /=(double d); 00092 Coord operator *(double d) const; 00097 Coord operator /(double d) const; 00098 00103 double& operator [](int i) ; 00108 double operator [](int i) const; 00109 00115 friend double dot(const Coord& c1, const Coord& c2); 00121 friend Coord cross(const Coord& c1, const Coord& c2); 00122 00127 double sqrabs() const; 00132 double abs() const; 00136 Coord unit() const; 00138 void normalize(); 00139 00140 }; 00141 00145 class Coord2D 00146 { 00147 public: 00149 double x; 00151 double y; 00152 00153 public: 00155 Coord2D(); 00160 Coord2D(double x, double y = 0.0); 00165 void setCoords(double x = 0.0, double y = 0.0); 00166 00171 Coord2D& operator +=(const Coord2D &coord); 00176 Coord2D& operator -=(const Coord2D &coord); 00181 Coord2D operator +(const Coord2D &coord) const; 00186 Coord2D operator -(const Coord2D &coord) const; 00190 Coord2D operator -() const; 00196 bool operator ==(const Coord2D &coord) const; 00202 Coord2D& operator =(const Coord2D &coord); 00203 00208 Coord2D& operator *=(double d); 00213 Coord2D& operator /=(double d); 00218 Coord2D operator *(double d) const; 00223 Coord2D operator /(double d) const; 00224 00229 double& operator [](int i) ; 00234 double operator [](int i) const; 00235 00241 friend double dot(const Coord2D& c1, const Coord2D& c2); 00242 00247 double sqrabs() const; 00252 double abs() const; 00256 Coord2D unit() const; 00258 void normalize(); 00259 00260 }; 00261 00262 #endif