proj home

Files   Classes   Functions   Hierarchy  

d2homogeneoustest.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void d2homogeneoustest01 ()


Function Documentation

void d2homogeneoustest01 (  ) 

Definition at line 7 of file d2homogeneoustest.cpp.

References degtorad, d2homogeneous::matrixMultiply(), d2homogeneous::setRotate(), d2homogeneous::setTranslate(), SHOW, point3< T >::x, and point3< T >::y.

Referenced by main().

00008 {
00009   cout << "Testing d2homogeneous class." << endl << endl;
00010 
00011   doublec pi=3.141592654;
00012 
00013   doublec degtorad = pi/180.0;
00014 
00015 
00016   cout << "Testing rotation with firstly a homogenouse point";
00017   cout << "  and then a normal point." << endl;
00018 
00019   d2homogeneous R;
00020   R.setRotate(90.0*degtorad);
00021 
00022   point3<double> p0(1.0,0.0,1.0);  // (1.0,0.0)
00023   point3<double> p(p0);
00024   cout << "before rotation  " << SHOW(p) << endl;
00025   R.matrixMultiply(p,p0);
00026   cout << "after rotation   " << SHOW(p) << endl;
00027 
00028   point2<double> q0(p0.x,p0.y);
00029   point2<double> q(q0);
00030 
00031   cout << "before rotation  " << SHOW(q) << endl;
00032   R.matrixMultiply(q,q0);
00033   cout << "after rotation   " << SHOW(q) << endl;
00034   cout << endl;
00035 
00036   cout << "Testing translation by now shifting the point" << endl;
00037   cout << SHOW(q) << endl;
00038   point2<double> dq(-0.5,-2.0);
00039   cout << SHOW(dq) << endl;
00040   cout << "q = q + dq" << endl;
00041   R.setTranslate(dq);
00042   cout << "R=" << endl;
00043   cout << (string)R << endl;
00044   
00045 //  point2<double> t(q);
00046 //  cout << SHOW(t) << endl;
00047   R.matrixMultiply(q);
00048   cout << SHOW(q) << endl << endl;
00049 
00050   cout << "Now both rotate the point and translate the " << endl;
00051   cout << "  point as a combined transformation" << endl;
00052   
00053   R.setRotate(90.0*degtorad);
00054   d2homogeneous T1;
00055   T1.setTranslate(dq);
00056   T1*R;
00057   q=q0;
00058   cout << SHOW(q) << endl;
00059   T1.matrixMultiply(q);
00060   cout << SHOW(q) << endl << endl;
00061 
00062   cout << "Testing rotating about a point.  Consider a unit" << endl;
00063   cout << "  circle with center at (2,2).  Rotating the top" << endl;
00064   cout << "  point (2,3) by 90 degrees about (2,2) should give " << endl;
00065   cout << "  { (1,2), (2,1), (3,2), (2,3) }" << endl;
00066 
00067   point2<double> center(2.0,2.0);
00068   cout << SHOW(center) << endl;
00069   q = point2<double>(2.0,3.0);
00070   R.setRotateAboutPoint(90.0*degtorad,center);
00071   cout << SHOW(q) << endl;
00072   R.matrixMultiply(q);  
00073   cout << SHOW(q) << endl;
00074   R.matrixMultiply(q);  
00075   cout << SHOW(q) << endl;
00076   R.matrixMultiply(q);  
00077   cout << SHOW(q) << endl;
00078   R.matrixMultiply(q);  
00079   cout << SHOW(q) << endl;
00080 }


Generated on Fri Mar 4 00:49:40 2011 for Chelton Evans Source by  doxygen 1.5.8