Files Classes Functions Hierarchy
00001 #include <cmath> 00002 using namespace std; 00003 00004 #include <d3tesstransform.h> 00005 00006 00007 d3tesstransform::d3tesstransform(d3tess & _tess) 00008 : tess(_tess) 00009 { 00010 } 00011 00012 00013 void d3tesstransform::multiply( pt2c & row1, pt2c & row2 ) 00014 { 00015 vector<pt3> & pt(tess.pt); 00016 uintc sz = pt.size(); 00017 for ( uint i=1; i<sz; ++i ) 00018 { 00019 pt2c w(pt[i]); 00020 pt[i].x = row1.dot(w); 00021 pt[i].y = row2.dot(w); 00022 } 00023 } 00024 00025 void d3tesstransform::translate( pt2c & x ) 00026 { 00027 vector<pt3> & pt(tess.pt); 00028 uintc sz = pt.size(); 00029 for ( uint i=1; i<sz; ++i ) 00030 { 00031 pt[i].x += x.x; 00032 pt[i].y += x.y; 00033 } 00034 } 00035 00036 void d3tesstransform::rotate(double const theta) 00037 { 00038 double const cos_t = cos(theta); 00039 double const sin_t = sin(theta); 00040 pt2c r1(cos_t,-sin_t); 00041 pt2c r2(sin_t,cos_t); 00042 00043 multiply(r1,r2); 00044 } 00045 00046 00047 void d3tesstransform::transEval() 00048 { 00049 vector<pt3> & pt(tess.pt); 00050 uintc sz = pt.size(); 00051 point3<double> t; 00052 point3<double> *p; 00053 double c; 00054 for ( uint i=1; i<sz; ++i ) 00055 { 00056 p = & pt[i]; 00057 // Preserve the c value of the point 00058 c = p->z; 00059 t.x = p->x; 00060 t.y = p->y; 00061 // Homogeneous points have 1 as their z value 00062 t.z = 1.0; 00063 00064 trans.matrixMultiply(*p,t); 00065 00066 // Restore the c value of the point 00067 p->z = c; 00068 } 00069 } 00070 00071 00072 00073
1.5.8