PLearn 0.1
|
00001 #include <cstdio> 00002 #include <boost/config.hpp> 00003 #include "SurfaceMesh.h" 00004 #include "geometry.h" 00005 00006 using namespace PLearn; 00007 using namespace std; 00008 using namespace boost; 00009 00010 00012 00013 00014 int main( int argc, char** argv ) 00015 { 00016 try 00017 { 00018 00019 /* 00020 SurfMesh sm = new SurfaceMesh(); 00021 00022 sm->readVRMLIndexedFaceSet 00023 ( "/u/lamblinp/work/test/vrml/bidon.vrml" ); 00024 00025 00026 Mat rot = rotationFromFixedAngles( 15, 0, 0 ); 00027 transformMesh( rot, Vec(3), sm ); 00028 00029 sm->writeVRMLIndexedFaceSet 00030 ( "/u/lamblinp/work/test/vrml/bidon_rot.vrml" ); 00031 */ 00032 00033 00034 00035 cout << "rot = rotationFromFixedAngles( 0, 0, 15 ): " << endl; 00036 Mat rot = rotationFromFixedAngles( 0, 0, 15 ); 00037 cout << rot << endl; 00038 00039 cout << "ang = fixedAnglesFromRotation( rot ): " << endl; 00040 Vec ang = fixedAnglesFromRotation( rot ); 00041 cout << ang << endl; 00042 00043 cout << "uz = [ 0 0 1 ]:" << endl; 00044 Vec uz( 3 ); 00045 uz << "0 0 1"; 00046 cout << uz << endl; 00047 00048 cout << "rot = rotationFromAxisAngle( uz, 15*DEG2RAD ):" << endl; 00049 rot << rotationFromAxisAngle( uz, 15*DEG2RAD ); 00050 cout << rot << endl; 00051 00052 cout << "ang = fixedAnglesFromRotation( rot ): " << endl; 00053 ang << fixedAnglesFromRotation( rot ); 00054 cout << ang << endl; 00055 00056 cout << "-----------------" << endl; 00057 00058 00059 cout << "trans = [ 2 3 5 ]" << endl; 00060 Vec trans( 3 ); 00061 trans << "2 3 5"; 00062 cout << trans << endl; 00063 00064 cout << "points: " << endl; 00065 string points_s = "0 0 0 1 0 0 1 1 0 0 1 1" ; 00066 Mat points( 4, 3 ); 00067 points << points_s; 00068 cout << points << endl; 00069 00070 /* 00071 cout << "rpoints: " << endl; 00072 Mat rpoints( 4, 3 ); 00073 productTranspose( rpoints, points, rot ); 00074 cout << rpoints << endl; 00075 */ 00076 00077 /* 00078 cout << "tpoints: " << endl; 00079 Mat tpoints( 4, 3 ); 00080 tpoints = points + trans; 00081 */ 00082 00083 cout << "tpoints: " << endl; 00084 Mat tpoints( 4, 3 ); 00085 transformPoints( rot, trans, points, tpoints ); 00086 cout << tpoints << endl; 00087 00088 // cout << "weights = [ 0 .33 .33 .34 ]:" << endl; 00089 cout << "weights = Vec( 4, .25 ):" << endl; 00090 Vec weights( 4, .25 ); 00091 cout << weights << endl; 00092 00093 real error=0; 00094 00095 cout << "weightedTranformationFromMatchedPoints( tpoints, points, weights, rot, trans, error ):" << endl; 00096 weightedTransformationFromMatchedPoints( tpoints, points, weights, rot, trans, error ) ; 00097 cout << "rot = " << endl << rot << endl; 00098 cout << "trans = " << trans << endl; 00099 cout << "error = " << error << endl; 00100 00101 cout << "------" << endl; 00102 00103 /* 00104 cout << "ang = fixedAnglesFromRotation( rot ): " << endl; 00105 ang << fixedAnglesFromRotation( rot ); 00106 cout << ang << endl; 00107 00108 cout << "error = " << error << endl; 00109 00110 cout << "rot = rotationFromFixedAngles( ang[0], ang[1], ang[2] ): " << endl; 00111 rot << rotationFromFixedAngles( ang[0], ang[1], ang[2] ); 00112 cout << rot << endl; 00113 */ 00114 cout << "fpoints: " << endl; 00115 Mat fpoints( 4, 3 ); 00116 transformPoints( rot, trans, tpoints, fpoints ); 00117 cout << fpoints << endl; 00118 00119 cout << "-----------------" << endl; 00120 00121 00122 /* 00123 cout << "weightedTransformationFromMatchedPoints( points, rpoints, weights, rot, trans, error ):" << endl; 00124 Vec trans( 3 ); 00125 weightedTransformationFromMatchedPoints( points, rpoints, weights, rot, trans, error ); 00126 cout << "rot = " << endl << rot << endl; 00127 cout << "trans = " << trans << endl; 00128 00129 cout << "ang = fixedAnglesFromRotation( rot ): " << endl; 00130 ang << fixedAnglesFromRotation( rot ); 00131 cout << ang << endl; 00132 00133 cout << "error = " << error << endl; 00134 00135 cout << "fpoints: " << endl; 00136 productTranspose( fpoints, rpoints, rot ); 00137 fpoints += trans; 00138 cout << fpoints << endl; 00139 */ 00140 00141 } 00142 catch( PLearnError e ) 00143 { 00144 cout << e.message() << endl; 00145 } 00146 return 0; 00147 } 00148