00001 #ifndef icMatrix_is_defined
00002 #define icMatrix_is_defined
00003
00004 class icMatrix2x2;
00005 class icMatrix3x3;
00006
00007 extern "C" {
00008 #include <math.h>
00009 #include <stdlib.h>
00010 }
00011 #include "icVector.h"
00012
00013
00014 class icMatrix2x2 {
00015 public:
00016 inline icMatrix2x2();
00017 inline icMatrix2x2(double x);
00018 inline icMatrix2x2(const icMatrix2x2 &that);
00019
00020 inline icMatrix2x2(double M00, double M01,
00021 double M10, double M11);
00022 inline icMatrix2x2(double M[2][2]);
00023
00024 inline icMatrix2x2 &set (const double d);
00025 inline icMatrix2x2 &operator=(const double d);
00026
00027 inline icMatrix2x2 &set (const icMatrix2x2 &that);
00028 inline icMatrix2x2 &operator=(const icMatrix2x2 &that);
00029
00030 inline icMatrix2x2 &set (double M[2][2]);
00031 inline icMatrix2x2 &operator=(double M[2][2]);
00032
00033 inline int operator!=(const icMatrix2x2 &that)const;
00034 inline int operator==(const icMatrix2x2 &that)const;
00035
00036 inline int operator==(double d) const;
00037 inline int operator!=(double d) const;
00038
00039 inline icMatrix2x2 &operator+=(double d);
00040 inline icMatrix2x2 &operator-=(double d);
00041 inline icMatrix2x2 &operator*=(double d);
00042
00043
00044 inline icMatrix2x2 &operator+=(const icMatrix2x2 &that);
00045 inline icMatrix2x2 &operator-=(const icMatrix2x2 &that);
00046 inline icMatrix2x2 &operator*=(const icMatrix2x2 &that);
00047
00048
00049
00050 icMatrix2x2 &leftMultiply (const icMatrix2x2 &that);
00051 icMatrix2x2 &rightMultiply(const icMatrix2x2 &that);
00052
00053 inline icMatrix2x2 &setIdentity ();
00054
00055 public:
00056 double entry[2][2];
00057
00058 };
00059
00060 inline icMatrix2x2 operator+(const icMatrix2x2 &a, double b);
00061 inline icMatrix2x2 operator-(const icMatrix2x2 &a, double b);
00062 inline icMatrix2x2 operator*(const icMatrix2x2 &a, double b);
00063
00064 inline icMatrix2x2 operator+(const icMatrix2x2 &a, const icMatrix2x2 &b);
00065 inline icMatrix2x2 operator-(const icMatrix2x2 &a, const icMatrix2x2 &b);
00066 inline icMatrix2x2 operator*(const icMatrix2x2 &a, const icMatrix2x2 &b);
00067
00068 inline icMatrix2x2 multiply(const icMatrix2x2 &a, const icMatrix2x2 &b);
00069 inline icVector2 operator*(const icMatrix2x2 &a, const icVector2 &b);
00070 inline icVector2 operator*(const icVector2 &a, const icMatrix2x2 &b);
00071
00072 inline double determinant(const icMatrix2x2 &a);
00073
00074 inline icMatrix2x2 transpose(const icMatrix2x2 &a);
00075 inline icMatrix2x2 inverse(const icMatrix2x2 &a);
00076
00077 inline icMatrix2x2::icMatrix2x2() {
00078 entry[0][0] = 1;
00079 entry[0][1] = 0;
00080 entry[1][0] = 0;
00081 entry[1][1] = 1;
00082 }
00083
00084 inline icMatrix2x2::icMatrix2x2(double x) {
00085 entry[0][0] = x;
00086 entry[0][1] = x;
00087 entry[1][0] = x;
00088 entry[1][1] = x;
00089 }
00090
00091 inline icMatrix2x2::icMatrix2x2(double M00, double M01,
00092 double M10, double M11) {
00093 entry[0][0] = M00;
00094 entry[0][1] = M01;
00095 entry[1][0] = M10;
00096 entry[1][1] = M11;
00097 };
00098
00099 inline icMatrix2x2::icMatrix2x2(const icMatrix2x2 &that) {
00100 entry[0][0] = that.entry[0][0];
00101 entry[0][1] = that.entry[0][1];
00102 entry[1][0] = that.entry[1][0];
00103 entry[1][1] = that.entry[1][1];
00104 };
00105
00106 inline icMatrix2x2 &icMatrix2x2::set(const double d) {
00107 return (*this)=d;
00108 }
00109
00110 inline icMatrix2x2 &icMatrix2x2::operator=(const double d) {
00111 entry[0][0] = d;
00112 entry[0][1] = d;
00113
00114 entry[1][0] = d;
00115 entry[1][1] = d;
00116 return (*this);
00117 };
00118
00119 inline icMatrix2x2 &icMatrix2x2::set(const icMatrix2x2 &that) {
00120 return (*this)=that;
00121 }
00122
00123 inline icMatrix2x2 &icMatrix2x2::operator=(const icMatrix2x2 &that) {
00124 entry[0][0] = that.entry[0][0];
00125 entry[0][1] = that.entry[0][1];
00126
00127 entry[1][0] = that.entry[1][0];
00128 entry[1][1] = that.entry[1][1];
00129 return (*this);
00130 };
00131
00132 inline icMatrix2x2 &icMatrix2x2::set(double M[2][2]) {
00133 return (*this)=M;
00134 }
00135
00136 inline icMatrix2x2 &icMatrix2x2::operator=(double M[2][2]) {
00137 entry[0][0] = M[0][0];
00138 entry[0][1] = M[0][1];
00139
00140 entry[1][0] = M[1][0];
00141 entry[1][1] = M[1][1];
00142 return (*this);
00143 };
00144
00145 inline int icMatrix2x2::operator==(double d) const {
00146 return ( (entry[0][0] == d) &&
00147 (entry[0][1] == d) &&
00148 (entry[1][0] == d) &&
00149 (entry[1][1] == d) );
00150 }
00151
00152 inline int icMatrix2x2::operator!=(double d) const {
00153 return ( (entry[0][0] != d) ||
00154 (entry[0][1] != d) ||
00155 (entry[1][0] != d) ||
00156 (entry[1][1] != d) );
00157 }
00158
00159 inline int icMatrix2x2::operator==(const icMatrix2x2 &that)const {
00160 return ( (entry[0][0] == that.entry[0][0]) &&
00161 (entry[0][1] == that.entry[0][1]) &&
00162 (entry[1][0] == that.entry[1][0]) &&
00163 (entry[1][1] == that.entry[1][1]) );
00164 }
00165
00166 inline int icMatrix2x2::operator!=(const icMatrix2x2 &that)const {
00167 return ( (entry[0][0] != that.entry[0][0]) ||
00168 (entry[0][1] != that.entry[0][1]) ||
00169 (entry[1][0] != that.entry[1][0]) ||
00170 (entry[1][1] != that.entry[1][1]) );
00171 }
00172
00173 inline icMatrix2x2 &icMatrix2x2::operator+=(double d) {
00174 entry[0][0] += d; entry[1][0] += d;
00175 entry[0][1] += d; entry[1][1] += d;
00176 return (*this);
00177 }
00178
00179 inline icMatrix2x2 &icMatrix2x2::operator-=(double d) {
00180 entry[0][0] -= d; entry[1][0] -= d;
00181 entry[0][1] -= d; entry[1][1] -= d;
00182 return (*this);
00183 }
00184
00185 inline icMatrix2x2 &icMatrix2x2::operator*=(double d) {
00186 entry[0][0] *= d; entry[1][0] *= d;
00187 entry[0][1] *= d; entry[1][1] *= d;
00188 return (*this);
00189 }
00190
00191 inline icMatrix2x2 &icMatrix2x2::operator+=(const icMatrix2x2 &that) {
00192 entry[0][0] += that.entry[0][0]; entry[1][0] += that.entry[1][0];
00193 entry[0][1] += that.entry[0][1]; entry[1][1] += that.entry[1][1];
00194 return (*this);
00195 }
00196
00197 inline icMatrix2x2 &icMatrix2x2::operator-=(const icMatrix2x2 &that) {
00198 entry[0][0] -= that.entry[0][0]; entry[1][0] -= that.entry[1][0];
00199 entry[0][1] -= that.entry[0][1]; entry[1][1] -= that.entry[1][1];
00200 return (*this);
00201 }
00202
00203 inline icMatrix2x2 &icMatrix2x2::operator*=(const icMatrix2x2 &that) {
00204 entry[0][0] *= that.entry[0][0]; entry[1][0] *= that.entry[1][0];
00205 entry[0][1] *= that.entry[0][1]; entry[1][1] *= that.entry[1][1];
00206 return (*this);
00207 }
00208
00209 inline icMatrix2x2 &icMatrix2x2::leftMultiply (const icMatrix2x2 &that){
00210 icMatrix2x2 tmp(entry[0][0], entry[0][1], entry[1][0], entry[1][1]);
00211
00212 entry[0][0] = that.entry[0][0] * tmp.entry[0][0] + that.entry[0][1] * tmp.entry[1][0];
00213 entry[0][1] = that.entry[0][0] * tmp.entry[0][1] + that.entry[0][1] * tmp.entry[1][1];
00214 entry[1][0] = that.entry[1][0] * tmp.entry[0][0] + that.entry[1][1] * tmp.entry[1][0];
00215 entry[1][1] = that.entry[1][0] * tmp.entry[0][1] + that.entry[1][1] * tmp.entry[1][1];
00216 return (*this);
00217 };
00218
00219 inline icMatrix2x2 &icMatrix2x2::rightMultiply(const icMatrix2x2 &that){
00220 icMatrix2x2 tmp(entry[0][0], entry[0][1], entry[1][0], entry[1][1]);
00221
00222 entry[0][0] = tmp.entry[0][0] * that.entry[0][0] + tmp.entry[0][1] * that.entry[1][0];
00223 entry[0][1] = tmp.entry[0][0] * that.entry[0][1] + tmp.entry[0][1] * that.entry[1][1];
00224 entry[1][0] = tmp.entry[1][0] * that.entry[0][0] + tmp.entry[1][1] * that.entry[1][0];
00225 entry[1][1] = tmp.entry[1][0] * that.entry[0][1] + tmp.entry[1][1] * that.entry[1][1];
00226 return (*this);
00227 };
00228
00229 inline icMatrix2x2 &icMatrix2x2::setIdentity() {
00230 entry[0][0] = 1; entry[0][1] = 0;
00231 entry[1][0] = 0; entry[1][1] = 1;
00232 return (*this);
00233 };
00234
00235 inline icMatrix2x2 operator+(const icMatrix2x2 &a,double b) {
00236 return (icMatrix2x2(a)+=b);
00237 }
00238
00239 inline icMatrix2x2 operator-(const icMatrix2x2 &a,double b) {
00240 return (icMatrix2x2(a)-=b);
00241 }
00242
00243 inline icMatrix2x2 operator*(const icMatrix2x2 &a,double b) {
00244 return (icMatrix2x2(a)*=b);
00245 }
00246
00247 inline icMatrix2x2 operator+(double a, const icMatrix2x2 &b) {
00248 return b+a;
00249 }
00250
00251 inline icMatrix2x2 operator-(double a, const icMatrix2x2 &b) {
00252 return icMatrix2x2(a-b.entry[0][0],a-b.entry[0][1],
00253 a-b.entry[1][0],a-b.entry[1][1]);
00254 }
00255
00256 inline icMatrix2x2 operator*(double a, const icMatrix2x2 &b) {
00257 return b*a;
00258 }
00259
00260 inline icMatrix2x2 operator+(const icMatrix2x2 &a,const icMatrix2x2 &b) {
00261 return (icMatrix2x2(a)+=b);
00262 }
00263
00264 inline icMatrix2x2 operator-(const icMatrix2x2 &a,const icMatrix2x2 &b) {
00265 return (icMatrix2x2(a)-=b);
00266 }
00267
00268 inline icMatrix2x2 operator*(const icMatrix2x2 &a,const icMatrix2x2 &b) {
00269 return (icMatrix2x2(a)*=b);
00270 }
00271
00272 inline icMatrix2x2 multiply(const icMatrix2x2 &a,const icMatrix2x2 &b) {
00273 icMatrix2x2 tmp(a);
00274 tmp.rightMultiply(b);
00275 return tmp;
00276 }
00277
00278 inline icVector2 operator*(const icMatrix2x2 &a,const icVector2 &b) {
00279 return icVector2(b.entry[0]*a.entry[0][0] + b.entry[1]*a.entry[0][1],
00280 b.entry[0]*a.entry[1][0] + b.entry[1]*a.entry[1][1]);
00281 }
00282
00283 inline icVector2 operator*(const icVector2 &a,const icMatrix2x2 &b) {
00284 return icVector2(a.entry[0]*b.entry[0][0] + a.entry[1]*b.entry[1][0],
00285 a.entry[0]*b.entry[0][1] + a.entry[1]*b.entry[1][1]);
00286 }
00287
00288 inline double determinant(const icMatrix2x2 &a) {
00289 return ( a.entry[0][0] * a.entry[1][1] - a.entry[0][1] * a.entry[1][0] );
00290 }
00291
00292 inline icMatrix2x2 transpose(const icMatrix2x2 &a) {
00293 icMatrix2x2 tmp(a);
00294
00295 tmp.entry[0][1] = a.entry[1][0];
00296 tmp.entry[1][0] = a.entry[0][1];
00297 return tmp;
00298 }
00299
00300 inline icMatrix2x2 inverse(const icMatrix2x2 &a) {
00301 icMatrix2x2 tmp;
00302 double dmt;
00303
00304 if ((dmt=determinant(a))!= 0.0) {
00305 tmp.entry[0][0] = a.entry[1][1]/dmt;
00306 tmp.entry[0][1] = -a.entry[0][1]/dmt;
00307 tmp.entry[1][0] = -a.entry[1][0]/dmt;
00308 tmp.entry[1][1] = a.entry[0][0]/dmt;
00309 }
00310 return tmp;
00311 }
00312
00313
00314 class icMatrix3x3 {
00315 public:
00316 inline icMatrix3x3();
00317 inline icMatrix3x3(double x);
00318 inline icMatrix3x3(const icMatrix3x3 &that);
00319 inline icMatrix3x3(const icVector3 &v1, const icVector3 &v2, const icVector3 &v3);
00320
00321 inline icMatrix3x3(double M00, double M01, double M02,
00322 double M10, double M11, double M12,
00323 double M20, double M21, double M22);
00324 inline icMatrix3x3(double M[3][3]);
00325
00326 inline icMatrix3x3 &set (const double d);
00327 inline icMatrix3x3 &operator=(const double d);
00328
00329 inline icMatrix3x3 &set (const icMatrix3x3 &that);
00330 inline icMatrix3x3 &operator=(const icMatrix3x3 &that);
00331
00332 inline icMatrix3x3 &set (double M[3][3]);
00333 inline icMatrix3x3 &operator=(double M[3][3]);
00334
00335 inline icMatrix3x3 &set (const icVector3 &v1, const icVector3 &v2, const icVector3 &v3);
00336 inline icMatrix3x3 &set (double M00, double M01, double M02,
00337 double M10, double M11, double M12,
00338 double M20, double M21, double M22);
00339 inline int operator!=(const icMatrix3x3 &that)const;
00340 inline int operator==(const icMatrix3x3 &that)const;
00341
00342 inline int operator==(double d) const;
00343 inline int operator!=(double d) const;
00344
00345 inline icMatrix3x3 &operator+=(double d);
00346 inline icMatrix3x3 &operator-=(double d);
00347 inline icMatrix3x3 &operator*=(double d);
00348
00349
00350 inline icMatrix3x3 &operator+=(const icMatrix3x3 &that);
00351 inline icMatrix3x3 &operator-=(const icMatrix3x3 &that);
00352 inline icMatrix3x3 &operator*=(const icMatrix3x3 &that);
00353
00354
00355
00356 icMatrix3x3 &leftMultiply (const icMatrix3x3 &that);
00357 icMatrix3x3 &rightMultiply(const icMatrix3x3 &that);
00358
00359 inline icMatrix3x3 &setIdentity ();
00360
00361 public:
00362 double entry[3][3];
00363
00364 };
00365
00366 inline icMatrix3x3 operator+(const icMatrix3x3 &a, double b);
00367 inline icMatrix3x3 operator-(const icMatrix3x3 &a, double b);
00368 inline icMatrix3x3 operator*(const icMatrix3x3 &a, double b);
00369
00370 inline icMatrix3x3 operator+(const icMatrix3x3 &a, const icMatrix3x3 &b);
00371 inline icMatrix3x3 operator-(const icMatrix3x3 &a, const icMatrix3x3 &b);
00372 inline icMatrix3x3 operator*(const icMatrix3x3 &a, const icMatrix3x3 &b);
00373
00374 inline icMatrix3x3 multiply(const icMatrix3x3 &a, const icMatrix3x3 &b);
00375 inline icMatrix3x3 conjugate(const icMatrix3x3 &a, const icMatrix3x3 &b);
00376 inline icMatrix3x3 othoconjugate(const icMatrix3x3 &a, const icMatrix3x3 &b);
00377 inline icVector3 operator*(const icMatrix3x3 &a, const icVector3 &b);
00378 inline icVector3 operator*(const icVector3 &a, const icMatrix3x3 &b);
00379
00380 inline double determinant(const icMatrix3x3 &a);
00381
00382 inline icMatrix3x3 transpose(const icMatrix3x3 &a);
00383 inline icMatrix3x3 inverse(const icMatrix3x3 &a);
00384
00385 inline icMatrix3x3::icMatrix3x3() {
00386 entry[0][0] = 1;
00387 entry[0][1] = 0;
00388 entry[0][2] = 0;
00389 entry[1][0] = 0;
00390 entry[1][1] = 1;
00391 entry[1][2] = 0;
00392 entry[2][0] = 0;
00393 entry[2][1] = 0;
00394 entry[2][2] = 1;
00395 }
00396
00397 inline icMatrix3x3::icMatrix3x3(double x) {
00398 entry[0][0] = x;
00399 entry[0][1] = x;
00400 entry[0][2] = x;
00401 entry[1][0] = x;
00402 entry[1][1] = x;
00403 entry[1][2] = x;
00404 entry[2][0] = x;
00405 entry[2][1] = x;
00406 entry[2][2] = x;
00407 }
00408
00409 inline icMatrix3x3::icMatrix3x3(double M00, double M01, double M02,
00410 double M10, double M11, double M12,
00411 double M20, double M21, double M22) {
00412 entry[0][0] = M00;
00413 entry[0][1] = M01;
00414 entry[0][2] = M02;
00415 entry[1][0] = M10;
00416 entry[1][1] = M11;
00417 entry[1][2] = M12;
00418 entry[2][0] = M20;
00419 entry[2][1] = M21;
00420 entry[2][2] = M22;
00421 };
00422
00423 inline icMatrix3x3::icMatrix3x3(const icMatrix3x3 &that) {
00424 entry[0][0] = that.entry[0][0];
00425 entry[0][1] = that.entry[0][1];
00426 entry[0][2] = that.entry[0][2];
00427 entry[1][0] = that.entry[1][0];
00428 entry[1][1] = that.entry[1][1];
00429 entry[1][2] = that.entry[1][2];
00430 entry[2][0] = that.entry[2][0];
00431 entry[2][1] = that.entry[2][1];
00432 entry[2][2] = that.entry[2][2];
00433 };
00434
00435 inline icMatrix3x3::icMatrix3x3(const icVector3 &v1, const icVector3 &v2, const icVector3 &v3) {
00436 entry[0][0] = v1.entry[0];
00437 entry[0][1] = v1.entry[1];
00438 entry[0][2] = v1.entry[2];
00439 entry[1][0] = v2.entry[0];
00440 entry[1][1] = v2.entry[1];
00441 entry[1][2] = v2.entry[2];
00442 entry[2][0] = v3.entry[0];
00443 entry[2][1] = v3.entry[1];
00444 entry[2][2] = v3.entry[2];
00445 }
00446
00447 inline icMatrix3x3 &icMatrix3x3::set(const double d) {
00448 return (*this)=d;
00449 }
00450
00451 inline icMatrix3x3 &icMatrix3x3::operator=(const double d) {
00452 entry[0][0] = d;
00453 entry[0][1] = d;
00454 entry[0][2] = d;
00455
00456 entry[1][0] = d;
00457 entry[1][1] = d;
00458 entry[1][2] = d;
00459
00460 entry[2][0] = d;
00461 entry[2][1] = d;
00462 entry[2][2] = d;
00463
00464 return (*this);
00465 };
00466
00467 inline icMatrix3x3 &icMatrix3x3::set(const icMatrix3x3 &that) {
00468 return (*this)=that;
00469 }
00470
00471 inline icMatrix3x3 &icMatrix3x3::operator=(const icMatrix3x3 &that) {
00472 entry[0][0] = that.entry[0][0];
00473 entry[0][1] = that.entry[0][1];
00474 entry[0][2] = that.entry[0][2];
00475 entry[1][0] = that.entry[1][0];
00476 entry[1][1] = that.entry[1][1];
00477 entry[1][2] = that.entry[1][2];
00478 entry[2][0] = that.entry[2][0];
00479 entry[2][1] = that.entry[2][1];
00480 entry[2][2] = that.entry[2][2];
00481 return (*this);
00482 };
00483
00484 inline icMatrix3x3 &icMatrix3x3::set(double M[3][3]) {
00485 return (*this)=M;
00486 }
00487
00488 inline icMatrix3x3 &icMatrix3x3::operator=(double M[3][3]) {
00489 entry[0][0] = M[0][0];
00490 entry[0][1] = M[0][1];
00491 entry[0][2] = M[0][2];
00492
00493 entry[1][0] = M[1][0];
00494 entry[1][1] = M[1][1];
00495 entry[1][2] = M[1][2];
00496
00497 entry[2][0] = M[2][0];
00498 entry[2][1] = M[2][1];
00499 entry[2][2] = M[2][2];
00500 return (*this);
00501 };
00502
00503 inline icMatrix3x3 &icMatrix3x3::set(const icVector3 &v1, const icVector3 &v2, const icVector3 &v3) {
00504 entry[0][0] = v1.entry[0];
00505 entry[0][1] = v1.entry[1];
00506 entry[0][2] = v1.entry[2];
00507 entry[1][0] = v2.entry[0];
00508 entry[1][1] = v2.entry[1];
00509 entry[1][2] = v2.entry[2];
00510 entry[2][0] = v3.entry[0];
00511 entry[2][1] = v3.entry[1];
00512 entry[2][2] = v3.entry[2];
00513 return (*this);
00514 }
00515
00516 inline icMatrix3x3 &icMatrix3x3::set (double M00, double M01, double M02,
00517 double M10, double M11, double M12,
00518 double M20, double M21, double M22)
00519 {
00520 entry[0][0] = M00;
00521 entry[0][1] = M01;
00522 entry[0][2] = M02;
00523 entry[1][0] = M10;
00524 entry[1][1] = M11;
00525 entry[1][2] = M12;
00526 entry[2][0] = M20;
00527 entry[2][1] = M21;
00528 entry[2][2] = M22;
00529 return (*this);
00530 }
00531
00532 inline int icMatrix3x3::operator==(double d) const {
00533 return ( (entry[0][0] == d) && (entry[0][1] == d) && (entry[0][2] == d) &&
00534 (entry[1][0] == d) && (entry[1][1] == d) && (entry[1][2] == d) &&
00535 (entry[2][0] == d) && (entry[2][1] == d) && (entry[2][2] == d));
00536 }
00537
00538 inline int icMatrix3x3::operator!=(double d) const {
00539 return ( (entry[0][0] != d) || (entry[0][1] != d) || (entry[0][2] != d) ||
00540 (entry[1][0] != d) || (entry[1][1] != d) || (entry[1][2] != d) ||
00541 (entry[2][0] != d) || (entry[2][1] != d) || (entry[2][2] != d));
00542 }
00543
00544 inline int icMatrix3x3::operator==(const icMatrix3x3 &that)const {
00545 return ( (entry[0][0] == that.entry[0][0]) && (entry[0][1] == that.entry[0][1]) && (entry[0][2] == that.entry[0][2]) &&
00546 (entry[1][0] == that.entry[1][0]) && (entry[1][1] == that.entry[1][1]) && (entry[1][2] == that.entry[1][2]) &&
00547 (entry[2][0] == that.entry[2][0]) && (entry[2][1] == that.entry[2][1]) && (entry[2][2] == that.entry[2][2]));
00548 }
00549
00550 inline int icMatrix3x3::operator!=(const icMatrix3x3 &that)const {
00551 return ( (entry[0][0] != that.entry[0][0]) || (entry[0][1] != that.entry[0][1]) || (entry[0][2] != that.entry[0][2]) ||
00552 (entry[1][0] != that.entry[1][0]) || (entry[1][1] != that.entry[1][1]) || (entry[1][2] != that.entry[1][2]) ||
00553 (entry[2][0] != that.entry[2][0]) || (entry[2][1] != that.entry[2][1]) || (entry[2][2] != that.entry[2][2]));
00554 }
00555
00556 inline icMatrix3x3 &icMatrix3x3::operator+=(double d) {
00557 entry[0][0] += d; entry[0][1] += d; entry[0][2] += d;
00558 entry[1][0] += d; entry[1][1] += d; entry[1][2] += d;
00559 entry[2][0] += d; entry[2][1] += d; entry[2][2] += d;
00560 return (*this);
00561 }
00562
00563 inline icMatrix3x3 &icMatrix3x3::operator-=(double d) {
00564 entry[0][0] -= d; entry[0][1] -= d; entry[0][2] -= d;
00565 entry[1][0] -= d; entry[1][1] -= d; entry[1][2] -= d;
00566 entry[2][0] -= d; entry[2][1] -= d; entry[2][2] -= d;
00567 return (*this);
00568 }
00569
00570 inline icMatrix3x3 &icMatrix3x3::operator*=(double d) {
00571 entry[0][0] *= d; entry[0][1] *= d; entry[0][2] *= d;
00572 entry[1][0] *= d; entry[1][1] *= d; entry[1][2] *= d;
00573 entry[2][0] *= d; entry[2][1] *= d; entry[2][2] *= d;
00574 return (*this);
00575 }
00576
00577 inline icMatrix3x3 &icMatrix3x3::operator+=(const icMatrix3x3 &that) {
00578 entry[0][0] += that.entry[0][0]; entry[0][1] += that.entry[0][1]; entry[0][2] += that.entry[0][2];
00579 entry[1][0] += that.entry[1][0]; entry[1][1] += that.entry[1][1]; entry[1][2] += that.entry[1][2];
00580 entry[2][0] += that.entry[2][0]; entry[2][1] += that.entry[2][1]; entry[2][2] += that.entry[2][2];
00581 return (*this);
00582 }
00583
00584 inline icMatrix3x3 &icMatrix3x3::operator-=(const icMatrix3x3 &that) {
00585 entry[0][0] -= that.entry[0][0]; entry[0][1] -= that.entry[0][1]; entry[0][2] -= that.entry[0][2];
00586 entry[1][0] -= that.entry[1][0]; entry[1][1] -= that.entry[1][1]; entry[1][2] -= that.entry[1][2];
00587 entry[2][0] -= that.entry[2][0]; entry[2][1] -= that.entry[2][1]; entry[2][2] -= that.entry[2][2];
00588 return (*this);
00589 }
00590
00591 inline icMatrix3x3 &icMatrix3x3::operator*=(const icMatrix3x3 &that) {
00592 entry[0][0] *= that.entry[0][0]; entry[0][1] *= that.entry[0][1]; entry[0][2] *= that.entry[0][2];
00593 entry[1][0] *= that.entry[1][0]; entry[1][1] *= that.entry[1][1]; entry[1][2] *= that.entry[1][2];
00594 entry[2][0] *= that.entry[2][0]; entry[2][1] *= that.entry[2][1]; entry[2][2] *= that.entry[2][2];
00595 return (*this);
00596 }
00597
00598 inline icMatrix3x3 &icMatrix3x3::leftMultiply (const icMatrix3x3 &that){
00599 icMatrix3x3 tmp(entry[0][0], entry[0][1], entry[0][2],
00600 entry[1][0], entry[1][1], entry[1][2],
00601 entry[2][0], entry[2][1], entry[2][2]);
00602
00603 entry[0][0] = that.entry[0][0] * tmp.entry[0][0] + that.entry[0][1] * tmp.entry[1][0] + that.entry[0][2] * tmp.entry[2][0];
00604 entry[0][1] = that.entry[0][0] * tmp.entry[0][1] + that.entry[0][1] * tmp.entry[1][1] + that.entry[0][2] * tmp.entry[2][1];
00605 entry[0][2] = that.entry[0][0] * tmp.entry[0][2] + that.entry[0][1] * tmp.entry[1][2] + that.entry[0][2] * tmp.entry[2][2];
00606
00607 entry[1][0] = that.entry[1][0] * tmp.entry[0][0] + that.entry[1][1] * tmp.entry[1][0] + that.entry[1][2] * tmp.entry[2][0];
00608 entry[1][1] = that.entry[1][0] * tmp.entry[0][1] + that.entry[1][1] * tmp.entry[1][1] + that.entry[1][2] * tmp.entry[2][1];
00609 entry[1][2] = that.entry[1][0] * tmp.entry[0][2] + that.entry[1][1] * tmp.entry[1][2] + that.entry[1][2] * tmp.entry[2][2];
00610
00611 entry[2][0] = that.entry[2][0] * tmp.entry[0][0] + that.entry[2][1] * tmp.entry[1][0] + that.entry[2][2] * tmp.entry[2][0];
00612 entry[2][1] = that.entry[2][0] * tmp.entry[0][1] + that.entry[2][1] * tmp.entry[1][1] + that.entry[2][2] * tmp.entry[2][1];
00613 entry[2][2] = that.entry[2][0] * tmp.entry[0][2] + that.entry[2][1] * tmp.entry[1][2] + that.entry[2][2] * tmp.entry[2][2];
00614 return (*this);
00615 };
00616
00617 inline icMatrix3x3 &icMatrix3x3::rightMultiply(const icMatrix3x3 &that){
00618 icMatrix3x3 tmp(entry[0][0], entry[0][1], entry[0][2],
00619 entry[1][0], entry[1][1], entry[1][2],
00620 entry[2][0], entry[2][1], entry[2][2]);
00621
00622 entry[0][0] = tmp.entry[0][0] * that.entry[0][0] + tmp.entry[0][1] * that.entry[1][0] + tmp.entry[0][2] * that.entry[2][0];
00623 entry[0][1] = tmp.entry[0][0] * that.entry[0][1] + tmp.entry[0][1] * that.entry[1][1] + tmp.entry[0][2] * that.entry[2][1];
00624 entry[0][2] = tmp.entry[0][0] * that.entry[0][2] + tmp.entry[0][1] * that.entry[1][2] + tmp.entry[0][2] * that.entry[2][2];
00625
00626 entry[1][0] = tmp.entry[1][0] * that.entry[0][0] + tmp.entry[1][1] * that.entry[1][0] + tmp.entry[1][2] * that.entry[2][0];
00627 entry[1][1] = tmp.entry[1][0] * that.entry[0][1] + tmp.entry[1][1] * that.entry[1][1] + tmp.entry[1][2] * that.entry[2][1];
00628 entry[1][2] = tmp.entry[1][0] * that.entry[0][2] + tmp.entry[1][1] * that.entry[1][2] + tmp.entry[1][2] * that.entry[2][2];
00629
00630 entry[2][0] = tmp.entry[2][0] * that.entry[0][0] + tmp.entry[2][1] * that.entry[1][0] + tmp.entry[2][2] * that.entry[2][0];
00631 entry[2][1] = tmp.entry[2][0] * that.entry[0][1] + tmp.entry[2][1] * that.entry[1][1] + tmp.entry[2][2] * that.entry[2][1];
00632 entry[2][2] = tmp.entry[2][0] * that.entry[0][2] + tmp.entry[2][1] * that.entry[1][2] + tmp.entry[2][2] * that.entry[2][2];
00633 return (*this);
00634 };
00635
00636 inline icMatrix3x3 &icMatrix3x3::setIdentity() {
00637 entry[0][0] = 1; entry[0][1] = 0; entry[0][2] = 0;
00638 entry[1][0] = 0; entry[1][1] = 1; entry[1][2] = 0;
00639 entry[2][0] = 0; entry[2][1] = 0; entry[2][2] = 1;
00640 return (*this);
00641 };
00642
00643 inline icMatrix3x3 operator+(const icMatrix3x3 &a,double b) {
00644 return (icMatrix3x3(a)+=b);
00645 }
00646
00647 inline icMatrix3x3 operator-(const icMatrix3x3 &a,double b) {
00648 return (icMatrix3x3(a)-=b);
00649 }
00650
00651 inline icMatrix3x3 operator*(const icMatrix3x3 &a,double b) {
00652 return (icMatrix3x3(a)*=b);
00653 }
00654
00655 inline icMatrix3x3 operator+(double a, const icMatrix3x3 &b) {
00656 return b+a;
00657 }
00658
00659 inline icMatrix3x3 operator-(double a, const icMatrix3x3 &b) {
00660 return icMatrix3x3(a-b.entry[0][0],a-b.entry[0][1],a-b.entry[0][2],
00661 a-b.entry[1][0],a-b.entry[1][1],a-b.entry[1][2],
00662 a-b.entry[2][0],a-b.entry[2][1],a-b.entry[2][2]);
00663 }
00664
00665 inline icMatrix3x3 operator*(double a, const icMatrix3x3 &b) {
00666 return b*a;
00667 }
00668
00669 inline icMatrix3x3 operator+(const icMatrix3x3 &a,const icMatrix3x3 &b) {
00670 return (icMatrix3x3(a)+=b);
00671 }
00672
00673 inline icMatrix3x3 operator-(const icMatrix3x3 &a,const icMatrix3x3 &b) {
00674 return (icMatrix3x3(a)-=b);
00675 }
00676
00677 inline icMatrix3x3 operator*(const icMatrix3x3 &a,const icMatrix3x3 &b) {
00678 return (icMatrix3x3(a)*=b);
00679 }
00680
00681 inline icMatrix3x3 multiply(const icMatrix3x3 &a,const icMatrix3x3 &b) {
00682 icMatrix3x3 tmp(a);
00683 tmp.rightMultiply(b);
00684 return tmp;
00685 }
00686
00687 inline icMatrix3x3 conjugate(const icMatrix3x3 a, const icMatrix3x3 &b) {
00688 icMatrix3x3 tmp(a);
00689 icMatrix3x3 c = inverse(b);
00690 tmp.rightMultiply(b);
00691 tmp.leftMultiply(c);
00692 return tmp;
00693 }
00694
00695 inline icMatrix3x3 othoconjugate(const icMatrix3x3 a, const icMatrix3x3 &b) {
00696 icMatrix3x3 tmp(a);
00697 icMatrix3x3 c = transpose(b);
00698 tmp.rightMultiply(b);
00699 tmp.leftMultiply(c);
00700 return tmp;
00701 }
00702
00703 inline icVector3 operator*(const icMatrix3x3 &a,const icVector3 &b) {
00704 return icVector3(b.entry[0]*a.entry[0][0] + b.entry[1]*a.entry[0][1] + b.entry[2]*a.entry[0][2],
00705 b.entry[0]*a.entry[1][0] + b.entry[1]*a.entry[1][1] + b.entry[2]*a.entry[1][2],
00706 b.entry[0]*a.entry[2][0] + b.entry[1]*a.entry[2][1] + b.entry[2]*a.entry[2][2]);
00707 }
00708
00709 inline icVector3 operator*(const icVector3 &a,const icMatrix3x3 &b) {
00710 return icVector3(a.entry[0]*b.entry[0][0] + a.entry[1]*b.entry[1][0] + a.entry[2]*b.entry[2][0],
00711 a.entry[0]*b.entry[0][1] + a.entry[1]*b.entry[1][1] + a.entry[2]*b.entry[2][1],
00712 a.entry[0]*b.entry[0][2] + a.entry[1]*b.entry[1][2] + a.entry[2]*b.entry[2][2]);
00713 }
00714
00715 inline double determinant(const icMatrix3x3 &a) {
00716 return ( a.entry[0][0] * a.entry[1][1] * a.entry[2][2] - a.entry[2][0] * a.entry[1][1] * a.entry[0][2]
00717 + a.entry[1][0] * a.entry[2][1] * a.entry[0][2] - a.entry[0][0] * a.entry[2][1] * a.entry[1][2]
00718 + a.entry[2][0] * a.entry[0][1] * a.entry[1][2] - a.entry[1][0] * a.entry[0][1] * a.entry[2][2]);
00719 }
00720
00721 inline icMatrix3x3 transpose(const icMatrix3x3 &a) {
00722 icMatrix3x3 tmp(a);
00723
00724 tmp.entry[0][1] = a.entry[1][0];
00725 tmp.entry[1][0] = a.entry[0][1];
00726
00727 tmp.entry[0][2] = a.entry[2][0];
00728 tmp.entry[2][0] = a.entry[0][2];
00729
00730 tmp.entry[2][1] = a.entry[1][2];
00731 tmp.entry[1][2] = a.entry[2][1];
00732 return tmp;
00733 }
00734
00735 inline icMatrix3x3 inverse(const icMatrix3x3 &a) {
00736 icMatrix3x3 tmp;
00737 double dmt;
00738
00739 if ((dmt=determinant(a))!= 0.0) {
00740 tmp.entry[0][0] = (a.entry[1][1] * a.entry[2][2] - a.entry[2][1] * a.entry[1][2])/dmt;
00741 tmp.entry[0][1] = (a.entry[2][1] * a.entry[0][2] - a.entry[0][1] * a.entry[2][2])/dmt;
00742 tmp.entry[0][2] = (a.entry[0][1] * a.entry[1][2] - a.entry[1][1] * a.entry[0][2])/dmt;
00743
00744 tmp.entry[1][0] = (a.entry[1][2] * a.entry[2][0] - a.entry[2][2] * a.entry[1][0])/dmt;
00745 tmp.entry[1][1] = (a.entry[2][2] * a.entry[0][0] - a.entry[0][2] * a.entry[2][0])/dmt;
00746 tmp.entry[1][2] = (a.entry[0][2] * a.entry[1][0] - a.entry[1][2] * a.entry[0][0])/dmt;
00747
00748 tmp.entry[2][0] = (a.entry[1][0] * a.entry[2][1] - a.entry[2][0] * a.entry[1][1])/dmt;
00749 tmp.entry[2][1] = (a.entry[2][0] * a.entry[0][1] - a.entry[0][0] * a.entry[2][1])/dmt;
00750 tmp.entry[2][2] = (a.entry[0][0] * a.entry[1][1] - a.entry[1][0] * a.entry[0][1])/dmt;
00751 }
00752 return tmp;
00753 }
00754
00755 #endif