Files Classes Functions Hierarchy
#include <halfspaceD3test.h>
Static Public Member Functions | |
| static void | test01 () |
| Basic 3D half space test. | |
| static void | test02 () |
| Test distancefromhalfspace. | |
| static void | test03 (int argc, char **argv) |
| Look at halfspaceD3 and halfspaceD3indexed. | |
Definition at line 7 of file halfspaceD3test.h.
| void halfspaceD3test::test01 | ( | ) | [static] |
Basic 3D half space test.
Definition at line 16 of file halfspaceD3test.cpp.
References halfspaceD3< PT, PD >::isInside(), halfspaceD3< PT, PD >::isInsideOrOnBoundary(), halfspaceD3< PT, PD >::normal, and SHOW.
Referenced by main().
00017 { 00018 typedef point3<double> pt3; 00019 00020 pt3 p0(0.0,0.0,0.0); 00021 pt3 p1(0.0,0.0,1.0); 00022 pt3 p2(1.0,0.0,0.0); 00023 00024 00025 halfspaceD3<pt3,double> h1(p0,p1,p2); 00026 00027 cout << endl; 00028 cout << "Half space (plane) from the ordered points." << endl; 00029 cout << SHOW(p0) << endl; 00030 cout << SHOW(p1) << endl; 00031 cout << SHOW(p2) << endl; 00032 cout << SHOW(h1.normal) << endl; 00033 00034 cout << "Enter a point: "; 00035 00036 pt3 p; 00037 cin >> p; 00038 00039 cout << SHOW(h1.isInside(p)) << endl; 00040 cout << SHOW(h1.isInsideOrOnBoundary(p)) << endl; 00041 00042 }
| void halfspaceD3test::test02 | ( | ) | [static] |
Test distancefromhalfspace.
Definition at line 44 of file halfspaceD3test.cpp.
References halfspaceD3< PT, PD >::distancefromhalfspace(), halfspaceD3< PT, PD >::normal, and SHOW.
Referenced by main().
00045 { 00046 typedef point3<double> pt3; 00047 00048 pt3 p0(0.0,0.0,0.0); 00049 pt3 p1(0.0,0.0,1.0); 00050 pt3 p2(1.0,0.0,0.0); 00051 halfspaceD3<pt3,double> h1(p0,p1,p2); 00052 00053 cout << endl; 00054 cout << "Half space (plane) from the ordered points." << endl; 00055 cout << SHOW(p0) << endl; 00056 cout << SHOW(p1) << endl; 00057 cout << SHOW(p2) << endl; 00058 00059 cout << SHOW(h1.normal) << endl; 00060 00061 cout << "Enter a point: "; 00062 00063 pt3 p; 00064 cin >> p; 00065 00066 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00067 00068 00069 }
| void halfspaceD3test::test03 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Look at halfspaceD3 and halfspaceD3indexed.
Definition at line 71 of file halfspaceD3test.cpp.
References aclock::diff_ms(), commandline::mapvar(), aclock::measure(), pts, r, and SHOW.
Referenced by main().
00072 { 00073 typedef point3<double> pt3; 00074 00075 random11<> r; 00076 00077 pt3 pts0[3] = 00078 { 00079 pt3(r(),r(),r()), 00080 pt3(r(),r(),r()), 00081 pt3(r(),r(),r()) 00082 // pt3(0.0,0.0,0.0), 00083 // pt3(0.0,0.0,1.0), 00084 // pt3(1.0,0.0,0.0) 00085 }; 00086 00087 halfspaceD3<pt3,double> h1(pts0,0,1,2); 00088 cout << SHOW(sizeof(h1)) << endl; 00089 00090 halfspaceD3indexed<pt3,double,uint> h2(pts0,0,1,2); 00091 cout << SHOW(sizeof(h2)) << endl; 00092 00093 halfspaceD3indexedfull<pt3,double,uint> h3(pts0,0,1,2); 00094 cout << SHOW(sizeof(h3)) << endl; 00095 00096 00097 commandline cmd(argc,argv); 00098 00099 uint N(1000); 00100 cmd.mapvar(N,"N"); 00101 00102 vector< pt3 > pts(N); 00103 for (uint i=0; i<N; ++i) 00104 pts[i] = pt3(r(),r(),r()); 00105 00106 uint count[3]; 00107 00108 partitionspace<pt3>* part[3]; 00109 part[0] = & h1; 00110 part[1] = & h2; 00111 part[2] = & h3; 00112 00113 for (uint k=0; k<3; ++k) 00114 { 00115 count[k]=0; 00116 00117 aclock ac; 00118 ac.measure(); 00119 00120 for (uint i=0; i<N; ++i) 00121 { 00122 if ( part[k]->isInside( pts[i] ) ) 00123 ++count[k]; 00124 } 00125 00126 ac.measure(); 00127 cout << "The event took " << ac.diff_ms() << "ms" << endl; 00128 } 00129 00130 cout << SHOW(count[0]) << endl; 00131 00132 assert(count[0]==count[1]); 00133 }
1.5.8