00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "dada.h"
00019
00020 using namespace Fluxus;
00021
00022 static const int SINCOS_TABLESIZE = 2048;
00023 static float SinTab[SINCOS_TABLESIZE];
00024 static float CosTab[SINCOS_TABLESIZE];
00025 static const float SINCOS_LOOKUP=SINCOS_TABLESIZE/(float)TWO_PI;
00026
00028
00029 float Fluxus::RandFloat()
00030 {
00031 return rand()%10000/10000.0f;
00032 }
00033
00034 float Fluxus::RandRange(float L, float H)
00035 {
00036 return ((rand()%10000/10000.0f)*(H-L))+L;
00037 }
00038
00039 void Fluxus::InitDada()
00040 {
00041 for (int n=0; n<SINCOS_TABLESIZE; n++)
00042 {
00043 float a=n*(TWO_PI/(float)SINCOS_TABLESIZE);
00044 SinTab[n]=sin(a);
00045 CosTab[n]=cos(a);
00046 }
00047 }
00048
00049 void Fluxus::dSinCos(float a, float &s, float &c)
00050 {
00051 int Index=(int)rint(a*SINCOS_LOOKUP)&SINCOS_TABLESIZE-1;
00052 s=SinTab[Index];
00053 c=CosTab[Index];
00054 }
00055
00056 dVector &dVector::operator=(dVector const &rhs)
00057 {
00058 x=rhs.x; y=rhs.y; z=rhs.z; w=rhs.w;
00059 return *this;
00060 }
00061
00062 dVector dVector::operator+(dVector const &rhs) const
00063 {
00064 dVector t;
00065 t.x=x+rhs.x; t.y=y+rhs.y; t.z=z+rhs.z;
00066 return t;
00067 }
00068
00069 dVector dVector::operator-(dVector const &rhs) const
00070 {
00071 dVector t;
00072 t.x=x-rhs.x; t.y=y-rhs.y; t.z=z-rhs.z;
00073 return t;
00074 }
00075
00076 dVector dVector::operator*(dVector const &rhs) const
00077 {
00078 dVector t;
00079 t.x=x*rhs.x; t.y=y*rhs.y; t.z=z*rhs.z;
00080 return t;
00081 }
00082
00083 dVector dVector::operator/(dVector const &rhs) const
00084 {
00085 dVector t;
00086 t.x=x/rhs.x; t.y=y/rhs.y; t.z=z/rhs.z;
00087 return t;
00088 }
00089
00090 dVector dVector::operator+(float rhs) const
00091 {
00092 dVector t;
00093 t.x=x+rhs; t.y=y+rhs; t.z=z+rhs;
00094 return t;
00095 }
00096
00097 dVector dVector::operator-(float rhs) const
00098 {
00099 dVector t;
00100 t.x=x-rhs; t.y=y-rhs; t.z=z-rhs;
00101 return t;
00102 }
00103
00104 dVector dVector::operator*(float rhs) const
00105 {
00106 dVector t;
00107 t.x=x*rhs; t.y=y*rhs; t.z=z*rhs;
00108 return t;
00109 }
00110
00111 dVector dVector::operator/(float rhs) const
00112 {
00113 dVector t;
00114 t.x=x/rhs; t.y=y/rhs; t.z=z/rhs;
00115 return t;
00116 }
00117
00118 dVector &dVector::operator+=(dVector const &rhs)
00119 {
00120 x+=rhs.x; y+=rhs.y; z+=rhs.z;
00121 return *this;
00122 }
00123
00124 dVector &dVector::operator-=(dVector const &rhs)
00125 {
00126 x-=rhs.x; y-=rhs.y; z-=rhs.z;
00127 return *this;
00128 }
00129
00130 dVector &dVector::operator*=(float rhs)
00131 {
00132 x*=rhs; y*=rhs; z*=rhs;
00133 return *this;
00134 }
00135
00136 dVector &dVector::operator/=(float rhs)
00137 {
00138 if (rhs) {x/=rhs; y/=rhs; z/=rhs;}
00139 return *this;
00140 }
00141
00142 float dVector::dot(dVector const &rhs) const
00143 {
00144 return x*rhs.x+y*rhs.y+z*rhs.z;
00145 }
00146
00147 dVector dVector::cross(dVector const &rhs) const
00148 {
00149 return dVector(y*rhs.z - z*rhs.y,
00150 z*rhs.x - x*rhs.z,
00151 x*rhs.y - y*rhs.x);
00152 }
00153
00154 dVector dVector::reflect(dVector const &rhs) const
00155 {
00156 float vdn=dot(rhs)*2.0f;
00157 return (*this)-rhs*vdn;
00158 }
00159
00160 float dVector::dist(dVector const &rhs) const
00161 {
00163 return sqrt((rhs.x-x)*(rhs.x-x)+
00164 (rhs.y-y)*(rhs.y-y)+
00165 (rhs.z-z)*(rhs.z-z));
00166 }
00167
00168 float dVector::distsq(dVector const &rhs) const
00169 {
00170 return (rhs.x-x)*(rhs.x-x)+
00171 (rhs.y-y)*(rhs.y-y)+
00172 (rhs.z-z)*(rhs.z-z);
00173 }
00174
00175 void dVector::get_euler(float &rx, float &ry, float &rz) const
00176 {
00177 if (z==0) rx=0;
00178 else rx=atan(y/z)*RAD_CONV;
00179 if (x==0) ry=0;
00180 else ry=atan(z/x)*RAD_CONV;
00181 if (y==0) rz=0;
00182 else rz=atan(x/y)*RAD_CONV;
00183 }
00184
00185 float dVector::mag()
00186 {
00187 return dist(dVector(0,0,0));
00188 }
00189
00190 dVector Fluxus::operator-(dVector rhs)
00191 {
00192 return dVector(-rhs.x,-rhs.y,-rhs.z);
00193 }
00194
00195 ostream &Fluxus::operator<<(ostream &os, dVector const &om)
00196 {
00197 os<<om.x<<" "<<om.y<<" "<<om.z<<" "<<om.w<<" ";
00198 return os;
00199 }
00200
00201 istream &Fluxus::operator>>(istream &is, dVector &om)
00202 {
00203 is>>om.x>>om.y>>om.z>>om.w;
00204 return is;
00205 }
00206
00207 void dVector::get_rot(float m[16],dVector up)
00208 {
00209 dVector a,b,c;
00210 a.x=this->x; a.y=this->y; a.z=this->z;
00211 a.normalise();
00212 if (a==up) a.x+=0.01;
00213 b=a.cross(up);
00214 b.normalise();
00215 c=b.cross(a);
00216 c.normalise();
00217
00218 for (int n=0; n<16; n++)
00219 {
00220 m[n]=0;
00221 }
00222
00223 m[15]=1;
00224
00225 m[0]=a.x; m[1]=a.y; m[2]=a.z;
00226 m[4]=b.x; m[5]=b.y; m[6]=b.z;
00227 m[8]=c.x; m[9]=c.y; m[10]=c.z;
00228 }
00229
00230 bool dVector::feq(const dVector &other, float epsilon)
00231 {
00232 return (fabs(x-other.x)<epsilon && fabs(y-other.y)<epsilon && fabs(z-other.z)<epsilon);
00233 }
00234
00236
00237 dColour &dColour::operator=(dColour const &rhs)
00238 {
00239 r=rhs.r; g=rhs.g; b=rhs.b; a=rhs.a;
00240 return *this;
00241 }
00242
00243 dColour dColour::operator+(dColour const &rhs) const
00244 {
00245 dColour t;
00246 t.r=r+rhs.r; t.g=g+rhs.g; t.b=b+rhs.b; t.a=a+rhs.a;
00247 return t;
00248 }
00249
00250 dColour dColour::operator-(dColour const &rhs) const
00251 {
00252 dColour t;
00253 t.r=r-rhs.r; t.g=g-rhs.g; t.b=b-rhs.b; t.a=a-rhs.a;
00254 return t;
00255 }
00256
00257 dColour dColour::operator*(dColour const &rhs) const
00258 {
00259 dColour t;
00260 t.r=r*rhs.r; t.g=g*rhs.g; t.b=b*rhs.b; t.a=a*rhs.a;
00261 return t;
00262 }
00263
00264 dColour dColour::operator/(dColour const &rhs) const
00265 {
00266 dColour t;
00267 t.r=r/rhs.r; t.g=g/rhs.g; t.b=b/rhs.b; t.a=a/rhs.a;
00268 return t;
00269 }
00270
00271 dColour dColour::operator+(float rhs) const
00272 {
00273 dColour t;
00274 t.r=r+rhs; t.g=g+rhs; t.b=b+rhs; t.a=a+rhs;
00275 return t;
00276 }
00277
00278 dColour dColour::operator-(float rhs) const
00279 {
00280 dColour t;
00281 t.r=r-rhs; t.g=g-rhs; t.b=b-rhs; t.a=a-rhs;
00282 return t;
00283 }
00284
00285 dColour dColour::operator*(float rhs) const
00286 {
00287 dColour t;
00288 t.r=r*rhs; t.g=g*rhs; t.b=b*rhs; t.a=a*rhs;
00289 return t;
00290 }
00291
00292 dColour dColour::operator/(float rhs) const
00293 {
00294 dColour t;
00295 t.r=r/rhs; t.g=g/rhs; t.b=b/rhs; t.a=a/rhs;
00296 return t;
00297 }
00298
00299 dColour &dColour::operator+=(dColour const &rhs)
00300 {
00301 r+=rhs.r; g+=rhs.g; b+=rhs.b; a+=rhs.a;
00302 return *this;
00303 }
00304
00305 dColour &dColour::operator-=(dColour const &rhs)
00306 {
00307 r-=rhs.r; g-=rhs.g; b-=rhs.b; a-=rhs.a;
00308 return *this;
00309 }
00310
00311 dColour &dColour::operator*=(float rhs)
00312 {
00313 r*=rhs; g*=rhs; b*=rhs; a*=rhs;
00314 return *this;
00315 }
00316
00317 dColour &dColour::operator/=(float rhs)
00318 {
00319 if (rhs) {r/=rhs; g/=rhs; b/=rhs; a/=rhs;}
00320 return *this;
00321 }
00322
00323 ostream &Fluxus::operator<<(ostream &os, dColour const &om)
00324 {
00325 os<<"r="<<om.r<<" g="<<om.g<<" b="<<om.b<<" a="<<om.a<<" ";
00326 return os;
00327 }
00328
00330
00331 dVertex const &dVertex::operator=(dVertex const &rhs)
00332 {
00333 point=rhs.point;
00334 normal=rhs.normal;
00335 col=rhs.col;
00336 s=rhs.s;
00337 t=rhs.t;
00338 return rhs;
00339 }
00340
00341 ostream &Fluxus::operator<<(ostream &os, dVertex const &v)
00342 {
00343 os<<"Vertex : p="<<v.point<<" n="<<v.normal<<v.col<<" "<<v.s<<" "<<v.t<<endl;
00344 return os;
00345 }
00346
00348
00349 dMatrix::dMatrix(float m00, float m10, float m20, float m30,
00350 float m01, float m11, float m21, float m31,
00351 float m02, float m12, float m22, float m32,
00352 float m03, float m13, float m23, float m33)
00353 {
00354 m[0][0]=m00; m[1][0]=m10; m[2][0]=m20; m[3][0]=m30;
00355 m[0][1]=m01; m[1][1]=m11; m[2][1]=m21; m[3][1]=m31;
00356 m[0][2]=m02; m[1][2]=m12; m[2][2]=m22; m[3][2]=m32;
00357 m[0][3]=m03; m[1][3]=m13; m[2][3]=m23; m[3][3]=m33;
00358 }
00359
00360 void dMatrix::init()
00361 {
00362 zero();
00363 m[0][0]=m[1][1]=m[2][2]=m[3][3]=1;
00364 }
00365
00366 void dMatrix::zero()
00367 {
00368 memset(m,0,sizeof(float)*16);
00369 }
00370
00371 const dMatrix &dMatrix::operator=(dMatrix const &rhs)
00372 {
00373 m[0][0]=rhs.m[0][0]; m[0][1]=rhs.m[0][1]; m[0][2]=rhs.m[0][2]; m[0][3]=rhs.m[0][3];
00374 m[1][0]=rhs.m[1][0]; m[1][1]=rhs.m[1][1]; m[1][2]=rhs.m[1][2]; m[1][3]=rhs.m[1][3];
00375 m[2][0]=rhs.m[2][0]; m[2][1]=rhs.m[2][1]; m[2][2]=rhs.m[2][2]; m[2][3]=rhs.m[2][3];
00376 m[3][0]=rhs.m[3][0]; m[3][1]=rhs.m[3][1]; m[3][2]=rhs.m[3][2]; m[3][3]=rhs.m[3][3];
00377 return rhs;
00378 }
00379
00380 dMatrix dMatrix::operator+(dMatrix const &rhs) const
00381 {
00382 dMatrix t;
00383 for (int i=0; i<4; i++)
00384 {
00385 for (int j=0; j<4; j++)
00386 {
00387 t.m[i][j]=m[i][j]+rhs.m[i][j];
00388 }
00389 }
00390 return t;
00391 }
00392
00393 dMatrix dMatrix::operator-(dMatrix const &rhs) const
00394 {
00395 dMatrix t;
00396 for (int i=0; i<4; i++)
00397 {
00398 for (int j=0; j<4; j++)
00399 {
00400 t.m[i][j]=m[i][j]-rhs.m[i][j];
00401 }
00402 }
00403 return t;
00404 }
00405
00406 dMatrix dMatrix::operator*(dMatrix const &rhs) const
00407 {
00408
00409
00410
00411
00412
00413
00414
00415
00416 dMatrix t;
00417
00418
00419
00420
00421
00422 t.m[0][0]=m[0][0]*rhs.m[0][0]+m[1][0]*rhs.m[0][1]+m[2][0]*rhs.m[0][2]+m[3][0]*rhs.m[0][3];
00423 t.m[0][1]=m[0][1]*rhs.m[0][0]+m[1][1]*rhs.m[0][1]+m[2][1]*rhs.m[0][2]+m[3][1]*rhs.m[0][3];
00424 t.m[0][2]=m[0][2]*rhs.m[0][0]+m[1][2]*rhs.m[0][1]+m[2][2]*rhs.m[0][2]+m[3][2]*rhs.m[0][3];
00425 t.m[0][3]=m[0][3]*rhs.m[0][0]+m[1][3]*rhs.m[0][1]+m[2][3]*rhs.m[0][2]+m[3][3]*rhs.m[0][3];
00426
00427 t.m[1][0]=m[0][0]*rhs.m[1][0]+m[1][0]*rhs.m[1][1]+m[2][0]*rhs.m[1][2]+m[3][0]*rhs.m[1][3];
00428 t.m[1][1]=m[0][1]*rhs.m[1][0]+m[1][1]*rhs.m[1][1]+m[2][1]*rhs.m[1][2]+m[3][1]*rhs.m[1][3];
00429 t.m[1][2]=m[0][2]*rhs.m[1][0]+m[1][2]*rhs.m[1][1]+m[2][2]*rhs.m[1][2]+m[3][2]*rhs.m[1][3];
00430 t.m[1][3]=m[0][3]*rhs.m[1][0]+m[1][3]*rhs.m[1][1]+m[2][3]*rhs.m[1][2]+m[3][3]*rhs.m[1][3];
00431
00432 t.m[2][0]=m[0][0]*rhs.m[2][0]+m[1][0]*rhs.m[2][1]+m[2][0]*rhs.m[2][2]+m[3][0]*rhs.m[2][3];
00433 t.m[2][1]=m[0][1]*rhs.m[2][0]+m[1][1]*rhs.m[2][1]+m[2][1]*rhs.m[2][2]+m[3][1]*rhs.m[2][3];
00434 t.m[2][2]=m[0][2]*rhs.m[2][0]+m[1][2]*rhs.m[2][1]+m[2][2]*rhs.m[2][2]+m[3][2]*rhs.m[2][3];
00435 t.m[2][3]=m[0][3]*rhs.m[2][0]+m[1][3]*rhs.m[2][1]+m[2][3]*rhs.m[2][2]+m[3][3]*rhs.m[2][3];
00436
00437 t.m[3][0]=m[0][0]*rhs.m[3][0]+m[1][0]*rhs.m[3][1]+m[2][0]*rhs.m[3][2]+m[3][0]*rhs.m[3][3];
00438 t.m[3][1]=m[0][1]*rhs.m[3][0]+m[1][1]*rhs.m[3][1]+m[2][1]*rhs.m[3][2]+m[3][1]*rhs.m[3][3];
00439 t.m[3][2]=m[0][2]*rhs.m[3][0]+m[1][2]*rhs.m[3][1]+m[2][2]*rhs.m[3][2]+m[3][2]*rhs.m[3][3];
00440 t.m[3][3]=m[0][3]*rhs.m[3][0]+m[1][3]*rhs.m[3][1]+m[2][3]*rhs.m[3][2]+m[3][3]*rhs.m[3][3];
00441
00442 return t;
00443 }
00444
00445 dMatrix dMatrix::operator/(dMatrix const &rhs) const
00446 {
00447 dMatrix t;
00448 for (int i=0; i<4; i++)
00449 {
00450 for (int j=0; j<4; j++)
00451 {
00452 t.m[i][j]=m[i][0]/rhs.m[0][j]+
00453 m[i][1]/rhs.m[1][j]+
00454 m[i][2]/rhs.m[2][j]+
00455 m[i][3]/rhs.m[3][j];
00456 }
00457 }
00458 return t;
00459 }
00460
00461 dMatrix dMatrix::operator+(float rhs) const
00462 {
00463 dMatrix t;
00464 for (int i=0; i<4; i++)
00465 {
00466 for (int j=0; j<4; j++)
00467 {
00468 t.m[i][j]=m[i][j]+rhs;
00469 }
00470 }
00471 return t;
00472 }
00473
00474 dMatrix dMatrix::operator-(float rhs) const
00475 {
00476 dMatrix t;
00477 for (int i=0; i<4; i++)
00478 {
00479 for (int j=0; j<4; j++)
00480 {
00481 t.m[i][j]=m[i][j]-rhs;
00482 }
00483 }
00484 return t;
00485 }
00486
00487 dMatrix dMatrix::operator*(float rhs) const
00488 {
00489 dMatrix t;
00490 for (int i=0; i<4; i++)
00491 {
00492 for (int j=0; j<4; j++)
00493 {
00494 t.m[i][j]=m[i][j]*rhs;
00495 }
00496 }
00497 return t;
00498 }
00499
00500 dMatrix dMatrix::operator/(float rhs) const
00501 {
00502 dMatrix t;
00503 for (int i=0; i<4; i++)
00504 {
00505 for (int j=0; j<4; j++)
00506 {
00507 t.m[i][j]=m[i][j]/rhs;
00508 }
00509 }
00510 return t;
00511 }
00512
00513 dMatrix &dMatrix::operator+=(dMatrix const &rhs)
00514 {
00515 for (int i=0; i<4; i++)
00516 {
00517 for (int j=0; j<4; j++)
00518 {
00519 m[i][j]+=rhs.m[i][j];
00520 }
00521 }
00522 return *this;
00523 }
00524
00525 dMatrix &dMatrix::operator-=(dMatrix const &rhs)
00526 {
00527 for (int i=0; i<4; i++)
00528 {
00529 for (int j=0; j<4; j++)
00530 {
00531 m[i][j]-=rhs.m[i][j];
00532 }
00533 }
00534 return *this;
00535 }
00536
00537 dMatrix &dMatrix::operator*=(dMatrix const &rhs)
00538 {
00539 *this=*this*rhs;
00540 return *this;
00541 }
00542
00543 dMatrix &dMatrix::operator/=(dMatrix const &rhs)
00544 {
00545 *this=*this/rhs;
00546 return *this;
00547 }
00548
00549 dMatrix &dMatrix::translate(float x, float y, float z)
00550 {
00551 dMatrix t;
00552 t.m[3][0]=x;
00553 t.m[3][1]=y;
00554 t.m[3][2]=z;
00555 *this=*this*t;
00556 return *this;
00557
00558 }
00559
00560 dMatrix &dMatrix::translate(dVector &tr)
00561 {
00562 dMatrix t;
00563 t.m[3][0]=tr.x;
00564 t.m[3][1]=tr.y;
00565 t.m[3][2]=tr.z;
00566 *this=*this*t;
00567 return *this;
00568
00569 }
00570
00571 void dMatrix::settranslate(dVector &tr)
00572 {
00573 m[3][0]=tr.x;
00574 m[3][1]=tr.y;
00575 m[3][2]=tr.z;
00576 }
00577
00578 dVector dMatrix::gettranslate() const
00579 {
00580 return dVector(m[3][0],m[3][1],m[3][2]);
00581 }
00582
00583
00584
00585 dMatrix &dMatrix::rotxyz(float x,float y,float z)
00586 {
00587 dMatrix t;
00588 if (x)
00589 {
00590 x*=0.017453292;
00591
00592 #ifdef USE_FAST_SINCOS
00593 float sx,cx;
00594 dSinCos(x,sx,cx);
00595 #else
00596 float sx=sin(x);
00597 float cx=cos(x);
00598 #endif
00599
00600 t.m[1][1]=cx;
00601 t.m[2][1]=-sx;
00602 t.m[1][2]=sx;
00603 t.m[2][2]=cx;
00604 *this=*this*t;
00605 }
00606
00607 if (y)
00608 {
00609 y*=0.017453292;
00610
00611 #ifdef USE_FAST_SINCOS
00612 float sy,cy;
00613 dSinCos(y,sy,cy);
00614 #else
00615 float sy=sin(y);
00616 float cy=cos(y);
00617 #endif
00618
00619 t.init();
00620 t.m[0][0]=cy;
00621 t.m[2][0]=-sy;
00622 t.m[0][2]=sy;
00623 t.m[2][2]=cy;
00624 *this=*this*t;
00625 }
00626
00627 if (z)
00628 {
00629 z*=0.017453292;
00630
00631 #ifdef USE_FAST_SINCOS
00632 float sz,cz;
00633 dSinCos(z,sz,cz);
00634 #else
00635 float sz=sin(z);
00636 float cz=cos(z);
00637 #endif
00638
00639 t.init();
00640 t.m[0][0]=cz;
00641 t.m[1][0]=-sz;
00642 t.m[0][1]=sz;
00643 t.m[1][1]=cz;
00644 *this=*this*t;
00645 }
00646
00647 return *this;
00648 }
00649
00650 dMatrix &dMatrix::rotx(float a)
00651 {
00652 a*=0.017453292;
00653 dMatrix t;
00654
00655 t.m[1][1]=cos(a);
00656 t.m[2][1]=-sin(a);
00657 t.m[1][2]=sin(a);
00658 t.m[2][2]=cos(a);
00659
00660 *this=*this*t;
00661 return *this;
00662 }
00663
00664 dMatrix &dMatrix::roty(float a)
00665 {
00666 a*=0.017453292;
00667 dMatrix t;
00668
00669 t.m[0][0]=cos(a);
00670 t.m[2][0]=-sin(a);
00671 t.m[0][2]=sin(a);
00672 t.m[2][2]=cos(a);
00673
00674 *this=*this*t;
00675 return *this;
00676 }
00677
00678 dMatrix &dMatrix::rotz(float a)
00679 {
00680 a*=0.017453292;
00681 dMatrix t;
00682
00683 t.m[0][0]=cos(a);
00684 t.m[1][0]=-sin(a);
00685 t.m[0][1]=sin(a);
00686 t.m[1][1]=cos(a);
00687
00688 *this=*this*t;
00689 return *this;
00690 }
00691
00692 dMatrix &dMatrix::scale(float x, float y, float z)
00693 {
00694 dMatrix t;
00695
00696 t.m[0][0]=x;
00697 t.m[1][1]=y;
00698 t.m[2][2]=z;
00699
00700 *this=*this*t;
00701 return *this;
00702 }
00703
00704 dVector dMatrix::transform(dVector const &p) const
00705 {
00706 dVector t;
00707 t.x=p.x*m[0][0] + p.y*m[1][0] + p.z*m[2][0] + p.w*m[3][0];
00708 t.y=p.x*m[0][1] + p.y*m[1][1] + p.z*m[2][1] + p.w*m[3][1];
00709 t.z=p.x*m[0][2] + p.y*m[1][2] + p.z*m[2][2] + p.w*m[3][2];
00710 t.w=p.x*m[0][3] + p.y*m[1][3] + p.z*m[2][3] + p.w*m[3][3];
00711 return t;
00712 }
00713
00714 dVector dMatrix::transform_persp(dVector const &p) const
00715 {
00716 dVector t;
00717 t.x=p.x*m[0][0] + p.y*m[1][0] + p.z*m[2][0] + p.w*m[3][0];
00718 t.y=p.x*m[0][1] + p.y*m[1][1] + p.z*m[2][1] + p.w*m[3][1];
00719 t.z=p.x*m[0][2] + p.y*m[1][2] + p.z*m[2][2] + p.w*m[3][2];
00720 t.w=p.x*m[0][3] + p.y*m[1][3] + p.z*m[2][3] + p.w*m[3][3];
00721 t.homog();
00722 return t;
00723 }
00724
00725 dVertex dMatrix::transform(dVertex const &p) const
00726 {
00727 dVertex t=p;
00728 t.point=transform(p.point);
00729 t.normal=transform_no_trans(p.normal);
00730 return t;
00731 }
00732
00733 dVector dMatrix::transform_no_trans(dVector const &p) const
00734 {
00735 dVector t;
00736 t.x=p.x*m[0][0] + p.y*m[1][0] + p.z*m[2][0];
00737 t.y=p.x*m[0][1] + p.y*m[1][1] + p.z*m[2][1];
00738 t.z=p.x*m[0][