icVector.h
Go to the documentation of this file.
00001 #ifndef icVector_is_defined
00002 #define icVector_is_defined
00003 
00004 
00005 class icVector2;
00006 class icVector3;
00007 
00008 // Start class icVector2
00009 extern "C" {
00010 #include <math.h>
00011 #include <stdlib.h>
00012 }
00013 //#include <iostream.h>
00014 
00015 class icVector2{
00016 public:
00017   inline icVector2();
00018   inline icVector2(double d);
00019   inline icVector2(double d0,double d1);
00020 
00021   inline icVector2(const icVector2 &a);
00022   inline icVector2(const double    *a);  
00023 
00024   inline icVector2 &set(double d);
00025   inline icVector2 &set(double d0, double d1);
00026 
00027   inline icVector2 &set(const icVector2 &a);
00028   inline icVector2 &set(const double    *a);  
00029 
00030   inline icVector2 &operator=(double d);
00031   inline icVector2 &operator=(const icVector2 &a);
00032   inline icVector2 &operator=(const double    *a);  
00033 
00034   inline int operator==(const icVector2 &a) const;
00035   inline int operator!=(const icVector2 &a) const;
00036 
00037   inline int operator==(double d) const;
00038   inline int operator!=(double d) const;
00039 
00040   inline icVector2 &operator+=(double d);
00041   inline icVector2 &operator-=(double d);
00042   inline icVector2 &operator*=(double d);
00043   inline icVector2 &operator/=(double d);
00044 
00045   inline icVector2 &operator+=(const icVector2 &a);
00046   inline icVector2 &operator-=(const icVector2 &a);
00047   inline icVector2 &operator*=(const icVector2 &a);
00048   inline icVector2 &operator/=(const icVector2 &a);
00049         inline double    length(const icVector2 &a);
00050         inline void normalize(icVector2 &a);
00051         
00052         inline double      dot(const icVector2 &a,const icVector2 &b);
00053         inline icVector2 cross(const icVector2 &a);
00054 
00055 public: 
00056         double entry[2];
00057 };
00058 
00059 inline icVector2 operator-(const icVector2 &a);
00060 
00061 inline icVector2 operator+(const icVector2 &a, const icVector2 &b);
00062 inline icVector2 operator-(const icVector2 &a, const icVector2 &b);
00063 
00064 inline icVector2 operator+(const icVector2 &a, double b);
00065 inline icVector2 operator-(const icVector2 &a, double b);
00066 inline icVector2 operator*(const icVector2 &a, double b);
00067 
00068 inline icVector2 operator+(double a, const icVector2 &b);
00069 inline icVector2 operator-(double a, const icVector2 &b);
00070 inline icVector2 operator*(double a, const icVector2 &b);
00071 
00072 inline double    length(const icVector2 &a);
00073 inline void normalize(icVector2 &a);
00074 
00075 
00076 inline double   dot(const icVector2 &a,const icVector2 &b);
00077 inline icVector2 cross(const icVector2 &a);
00078 
00079 inline icVector2::icVector2() {
00080   entry[0] = entry[1] = 0.0;
00081 }
00082 inline icVector2::icVector2(double d) {
00083   entry[0] = entry[1] = d;
00084 }
00085 
00086 inline icVector2::icVector2(double d0,double d1) {
00087   entry[0] = d0;
00088   entry[1] = d1;
00089 }
00090 
00091 inline icVector2::icVector2(const icVector2 &a) {
00092   entry[0] = a.entry[0];
00093   entry[1] = a.entry[1];
00094 }
00095 
00096 inline icVector2::icVector2(const double *a) {
00097   entry[0] = a[0];
00098   entry[1] = a[1];
00099 }
00100 
00101 inline icVector2 &icVector2::set(double d) {
00102   entry[0] = d;
00103   entry[1] = d;
00104   return (*this);
00105 }
00106   
00107 inline icVector2 &icVector2::set(double d0, double d1) {
00108   entry[0] = d0;
00109   entry[1] = d1;
00110   return (*this);
00111 }
00112 
00113 inline icVector2 &icVector2::set(const icVector2 &a) {
00114   entry[0] = a.entry[0];
00115   entry[1] = a.entry[1];
00116   return (*this);
00117 }
00118   
00119 inline icVector2 &icVector2::set(const double *a) {
00120   entry[0] = a[0];
00121   entry[1] = a[1];
00122   return (*this);
00123 }
00124   
00125 inline icVector2 operator-(const icVector2 &a) {
00126   return icVector2(-a.entry[0],-a.entry[1]);
00127 }
00128 
00129 inline icVector2 &icVector2::operator=(double d) {
00130   return set(d);
00131 }
00132  
00133 inline icVector2 &icVector2::operator=(const icVector2 &a) {
00134   return set(a);
00135 }
00136 
00137 inline icVector2 &icVector2::operator=(const double *a) {
00138   return set(a);
00139 }
00140   
00141 //-------------------------------------------------------------------
00142 
00143 inline int icVector2::operator==(const icVector2 &a) const {
00144   return ((entry[0] == a.entry[0]) &&
00145           (entry[1] == a.entry[1]));
00146 }
00147 
00148 inline int icVector2::operator!=(const icVector2 &a) const {
00149   return ((entry[0] != a.entry[0]) ||
00150           (entry[1] != a.entry[1]));
00151 }
00152   
00153 inline int icVector2::operator==(double d) const {
00154   return ((entry[0] == d) &&
00155           (entry[1] == d));
00156 }
00157 
00158 inline int icVector2::operator!=(double d) const {
00159   return ((entry[0] != d) ||
00160           (entry[1] != d));
00161 }
00162 
00163 //-------------------------------------------------------------------
00164 
00165 inline icVector2 &icVector2::operator+=(double d) {
00166   entry[0] += d;
00167   entry[1] += d;
00168   return (*this);
00169 }
00170     
00171 inline icVector2 &icVector2::operator-=(double d) {
00172   entry[0] -= d;
00173   entry[1] -= d;
00174   return (*this);
00175 }
00176 
00177 inline icVector2 &icVector2::operator*=(double d) {
00178   entry[0] *= d;
00179   entry[1] *= d;
00180   return (*this);
00181 }
00182 
00183 inline icVector2 &icVector2::operator+=(const icVector2 &a) {
00184   entry[0] += a.entry[0];
00185   entry[1] += a.entry[1];
00186   return (*this);
00187 }
00188 
00189 inline icVector2 &icVector2::operator-=(const icVector2 &a) {
00190   entry[0] -= a.entry[0];
00191   entry[1] -= a.entry[1];
00192   return (*this);
00193 }
00194 
00195 inline icVector2 &icVector2::operator*=(const icVector2 &a) {
00196   entry[0] *= a.entry[0];
00197   entry[1] *= a.entry[1];
00198   return (*this);
00199 }
00200 
00201 //-------------------------------------------------------------------
00202 
00203 inline icVector2 operator+(const icVector2 &a,const icVector2 &b) {
00204   return icVector2(a.entry[0] + b.entry[0], a.entry[1] + b.entry[1]);
00205 }
00206 
00207 inline icVector2 operator-(const icVector2 &a,const icVector2 &b) {
00208   return icVector2(a.entry[0] - b.entry[0], a.entry[1] - b.entry[1]);
00209 }
00210 
00211 inline icVector2 operator+(const icVector2 &a,double b){
00212   return icVector2(a.entry[0] + b, a.entry[1] + b);
00213 }
00214 
00215 inline icVector2 operator-(const icVector2 &a,double b){
00216   return icVector2(a.entry[0] - b, a.entry[1] - b);
00217 }
00218 
00219 inline icVector2 operator*(const icVector2 &a,double b){
00220   return icVector2(a.entry[0] * b, a.entry[1] * b);
00221 }
00222 
00223 inline icVector2 operator+(double a,const icVector2 &b){
00224   return icVector2(a + b.entry[0], a + b.entry[1]);
00225 }
00226 
00227 inline icVector2 operator-(double a,const icVector2 &b){
00228   return icVector2(a - b.entry[0], a - b.entry[1]);
00229 }
00230 
00231 inline icVector2 operator*(double a,const icVector2 &b){
00232   return icVector2(a * b.entry[0], a * b.entry[1]);
00233 }
00234 
00235 inline double length(const icVector2 &a) {
00236   return sqrt(a.entry[0] * a.entry[0] + a.entry[1] * a.entry[1]);
00237 }
00238 
00239 inline void normalize(icVector2 &a) {
00240   register double m = length(a);
00241   if (m != 0) a *= (1/m);
00242 }
00243 
00244 inline double dot(const icVector2 &a,const icVector2 &b) {
00245   return (a.entry[0] * b.entry[0] + a.entry[1] * b.entry[1]);
00246 }
00247   
00248 inline icVector2 cross(const icVector2 &a) {
00249   return icVector2(-a.entry[1], a.entry[0]);
00250 }
00251 
00252 // Start class icVector3
00253 class icVector3{
00254 public:
00255   inline icVector3();
00256   inline icVector3(double d);
00257   inline icVector3(double d0,double d1,double d2);
00258 
00259   inline icVector3(const icVector3 &a);
00260   inline icVector3(const double    *a);  
00261 
00262   inline icVector3 &set(double d);
00263   inline icVector3 &set(double d0, double d1,double d2);
00264 
00265   inline icVector3 &set(const icVector3 &a);
00266   inline icVector3 &set(const double    *a);  
00267 
00268   inline icVector3 &operator=(double d);
00269   inline icVector3 &operator=(const icVector3 &a);
00270   inline icVector3 &operator=(const double    *a);  
00271 
00272   inline int operator==(const icVector3 &a) const;
00273   inline int operator!=(const icVector3 &a) const;
00274 
00275   inline int operator==(double d) const;
00276   inline int operator!=(double d) const;
00277 
00278   inline icVector3 &operator+=(double d);
00279   inline icVector3 &operator-=(double d);
00280   inline icVector3 &operator*=(double d);
00281   inline icVector3 &operator/=(double d);
00282 
00283   inline icVector3 &operator+=(const icVector3 &a);
00284   inline icVector3 &operator-=(const icVector3 &a);
00285   inline icVector3 &operator*=(const icVector3 &a);
00286   inline icVector3 &operator/=(const icVector3 &a);
00287         inline double    length(const icVector3 &a);
00288         inline void normalize(icVector3 &a);
00289         
00290         inline double      dot(const icVector3 &a,const icVector3 &b);
00291         inline icVector3 cross(const icVector3 &a);
00292 
00293 public: 
00294         double entry[3];
00295 };
00296 
00297 inline icVector3 operator-(const icVector3 &a);
00298 
00299 inline icVector3 operator+(const icVector3 &a, const icVector3 &b);
00300 inline icVector3 operator-(const icVector3 &a, const icVector3 &b);
00301 
00302 inline icVector3 operator+(const icVector3 &a, double b);
00303 inline icVector3 operator-(const icVector3 &a, double b);
00304 inline icVector3 operator*(const icVector3 &a, double b);
00305 
00306 inline icVector3 operator+(double a, const icVector3 &b);
00307 inline icVector3 operator-(double a, const icVector3 &b);
00308 inline icVector3 operator*(double a, const icVector3 &b);
00309 
00310 inline double    length(const icVector3 &a);
00311 inline void normalize(icVector3 &a);
00312 
00313 
00314 inline double   dot(const icVector3 &a,const icVector3 &b);
00315 inline icVector3 cross(const icVector3 &a, const icVector3 &b);
00316 
00317 inline icVector3::icVector3() {
00318   entry[0] = entry[1] = entry[2] = 0.0;
00319 }
00320 inline icVector3::icVector3(double d) {
00321   entry[0] = entry[1] = entry[2] = d;
00322 }
00323 
00324 inline icVector3::icVector3(double d0,double d1,double d2) {
00325   entry[0] = d0;
00326   entry[1] = d1;
00327   entry[2] = d2;
00328 }
00329 
00330 inline icVector3::icVector3(const icVector3 &a) {
00331   entry[0] = a.entry[0];
00332   entry[1] = a.entry[1];
00333   entry[2] = a.entry[2];
00334 }
00335 
00336 inline icVector3::icVector3(const double *a) {
00337   entry[0] = a[0];
00338   entry[1] = a[1];
00339   entry[1] = a[2];
00340 }
00341   
00342 //-------------------------------------------------------------------
00343 
00344 inline icVector3 &icVector3::set(double d) {
00345   entry[0] = d;
00346   entry[1] = d;
00347   entry[2] = d;
00348   return (*this);
00349 }
00350   
00351 inline icVector3 &icVector3::set(double d0, double d1, double d2) {
00352   entry[0] = d0;
00353   entry[1] = d1;
00354   entry[2] = d2;
00355   return (*this);
00356 }
00357 
00358 inline icVector3 &icVector3::set(const icVector3 &a) {
00359   entry[0] = a.entry[0];
00360   entry[1] = a.entry[1];
00361   entry[2] = a.entry[2];
00362   return (*this);
00363 }
00364   
00365 inline icVector3 &icVector3::set(const double *a) {
00366   entry[0] = a[0];
00367   entry[1] = a[1];
00368   entry[2] = a[2];
00369   return (*this);
00370 }
00371   
00372 inline icVector3 operator-(const icVector3 &a) {
00373   return icVector3(-a.entry[0],-a.entry[1],-a.entry[2]);
00374 }
00375 
00376 inline icVector3 &icVector3::operator=(double d) {
00377   return set(d);
00378 }
00379  
00380 inline icVector3 &icVector3::operator=(const icVector3 &a) {
00381   return set(a);
00382 }
00383 
00384 inline icVector3 &icVector3::operator=(const double *a) {
00385   return set(a);
00386 }
00387   
00388 //-------------------------------------------------------------------
00389 
00390 inline int icVector3::operator==(const icVector3 &a) const {
00391   return ((entry[0] == a.entry[0]) &&
00392           (entry[1] == a.entry[1]) &&
00393           (entry[2] == a.entry[2]));
00394 }
00395 
00396 inline int icVector3::operator!=(const icVector3 &a) const {
00397   return ((entry[0] != a.entry[0]) ||
00398           (entry[1] != a.entry[1]) ||
00399           (entry[2] != a.entry[2]));
00400 }
00401   
00402 inline int icVector3::operator==(double d) const {
00403   return ((entry[0] == d) &&
00404           (entry[1] == d) &&
00405           (entry[2] == d));
00406 }
00407 
00408 inline int icVector3::operator!=(double d) const {
00409   return ((entry[0] != d) ||
00410           (entry[1] != d) ||
00411           (entry[2] != d));
00412 }
00413 
00414 //-------------------------------------------------------------------
00415 
00416 inline icVector3 &icVector3::operator+=(double d) {
00417   entry[0] += d;
00418   entry[1] += d;
00419   entry[2] += d;
00420   return (*this);
00421 }
00422     
00423 inline icVector3 &icVector3::operator-=(double d) {
00424   entry[0] -= d;
00425   entry[1] -= d;
00426   entry[2] -= d;
00427   return (*this);
00428 }
00429 
00430 inline icVector3 &icVector3::operator*=(double d) {
00431   entry[0] *= d;
00432   entry[1] *= d;
00433   entry[2] *= d;
00434   return (*this);
00435 }
00436 
00437 inline icVector3 &icVector3::operator+=(const icVector3 &a) {
00438   entry[0] += a.entry[0];
00439   entry[1] += a.entry[1];
00440   entry[2] += a.entry[2];
00441   return (*this);
00442 }
00443 
00444 inline icVector3 &icVector3::operator-=(const icVector3 &a) {
00445   entry[0] -= a.entry[0];
00446   entry[1] -= a.entry[1];
00447   entry[2] -= a.entry[2];
00448   return (*this);
00449 }
00450 
00451 inline icVector3 &icVector3::operator*=(const icVector3 &a) {
00452   entry[0] *= a.entry[0];
00453   entry[1] *= a.entry[1];
00454   entry[2] *= a.entry[2];
00455   return (*this);
00456 }
00457 
00458 //-------------------------------------------------------------------
00459 
00460 inline icVector3 operator+(const icVector3 &a,const icVector3 &b) {
00461   return icVector3(a.entry[0] + b.entry[0], a.entry[1] + b.entry[1], a.entry[2] + b.entry[2]);
00462 }
00463 
00464 inline icVector3 operator-(const icVector3 &a,const icVector3 &b) {
00465   return icVector3(a.entry[0] - b.entry[0], a.entry[1] - b.entry[1], a.entry[2] - b.entry[2]);
00466 }
00467 
00468 inline icVector3 operator+(const icVector3 &a,double b){
00469   return icVector3(a.entry[0] + b, a.entry[1] + b, a.entry[2] + b);
00470 }
00471 
00472 inline icVector3 operator-(const icVector3 &a,double b){
00473   return icVector3(a.entry[0] - b, a.entry[1] - b, a.entry[2] - b);
00474 }
00475 
00476 inline icVector3 operator*(const icVector3 &a,double b){
00477   return icVector3(a.entry[0] * b, a.entry[1] * b, a.entry[2] * b);
00478 }
00479 
00480 inline icVector3 operator+(double a,const icVector3 &b){
00481   return icVector3(a + b.entry[0], a + b.entry[1], a + b.entry[2]);
00482 }
00483 
00484 inline icVector3 operator-(double a,const icVector3 &b){
00485   return icVector3(a - b.entry[0], a - b.entry[1], a - b.entry[2]);
00486 }
00487 
00488 inline icVector3 operator*(double a,const icVector3 &b){
00489   return icVector3(a * b.entry[0], a * b.entry[1], a * b.entry[2]);
00490 }
00491 
00492 inline double length(const icVector3 &a) {
00493   return sqrt(a.entry[0] * a.entry[0] + a.entry[1] * a.entry[1] + a.entry[2] * a.entry[2]);
00494 }
00495 
00496 inline void normalize(icVector3 &a) {
00497   register double m = length(a);
00498   if (m != 0) a *= (1/m);
00499 }
00500 
00501 inline double dot(const icVector3 &a,const icVector3 &b) {
00502   return (a.entry[0] * b.entry[0] + a.entry[1] * b.entry[1] + a.entry[2] * b.entry[2]);
00503 }
00504   
00505 inline icVector3 cross(const icVector3 &a, const icVector3 &b) {
00506   return icVector3(a.entry[1] * b.entry[2] - a.entry[2] * b.entry[1], 
00507                                                                          a.entry[2] * b.entry[0] - a.entry[0] * b.entry[2],
00508                                                                          a.entry[0] * b.entry[1] - a.entry[1] * b.entry[0]);
00509 }
00510 
00511 #endif


tensor_field_nav_core
Author(s): Lintao Zheng, Kai Xu
autogenerated on Thu Jun 6 2019 19:50:56