Files Classes Functions Hierarchy
#include <halfspaceD2test.h>
Static Public Member Functions | |
| static void | test01 () |
| Basic 2D half-space test. | |
| static void | test02 () |
| Minimize a point to a the half-space line. | |
| static int | unittest01 () |
| Clip some lines with the half-space. | |
Definition at line 7 of file halfspaceD2test.h.
| void halfspaceD2test::test01 | ( | ) | [static] |
Basic 2D half-space test.
Definition at line 11 of file halfspaceD2test.cpp.
References partitionspace< PT >::classify(), halfspaceD2< PT, PD >::isInside(), halfspaceD2< PT, PD >::isInsideOrOnBoundary(), SHOW, point2< T >::x, and point2< T >::y.
Referenced by main().
00012 { 00013 cout << "halfspace h1(0,1)" << endl; 00014 cout << "Enter a point to test isinside: "; 00015 00016 typedef point2<double> pt2; 00017 pt2 p; 00018 cin >> p.x >> p.y; 00019 00020 halfspaceD2< pt2, double > h1(pt2(0.0,0.0),pt2(0.0,1.0)); 00021 00022 cout << SHOW (h1.isInside(p)) << endl; 00023 cout << SHOW (h1.isInsideOrOnBoundary(p)) << endl; 00024 cout << SHOW (partitionspace<pt2>::classifystring(h1.classify(p))) << endl; 00025 }
| void halfspaceD2test::test02 | ( | ) | [static] |
Minimize a point to a the half-space line.
Definition at line 28 of file halfspaceD2test.cpp.
References halfspaceD2< PT, PD >::distancefromhalfspace(), halfspaceD2< PT, PD >::minimizepointtoline(), halfspaceD2< PT, PD >::pointOnLine(), and SHOW.
Referenced by main().
00029 { 00030 cout << "Testing finding the minimum point on the line to the given point" << endl; 00031 typedef point2<double> pt2; 00032 pt2 p0(0.0,0.0); 00033 pt2 p1(1.0,0.0); 00034 cout << "line from " << p0 << " to " << p1 << endl; 00035 00036 halfspaceD2< pt2, double > h1(p0,p1); 00037 pt2 p(0.5,1.0); 00038 double t; 00039 h1.minimizepointtoline(t,p); 00040 pt2 pmin; 00041 h1.pointOnLine(pmin,t); 00042 cout << SHOW(t) << endl; 00043 cout << SHOW(pmin) << endl; 00044 00045 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00046 p=pt2(0.5,2.0); 00047 cout << SHOW(p) << endl; 00048 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00049 p=pt2(0.3,0.7); 00050 cout << SHOW(p) << endl; 00051 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00052 p=pt2(0.1,0.7); 00053 cout << SHOW(p) << endl; 00054 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00055 p=pt2(0.1,0.4); 00056 cout << SHOW(p) << endl; 00057 cout << SHOW(h1.distancefromhalfspace(p)) << endl; 00058 00059 }
| int halfspaceD2test::unittest01 | ( | ) | [static] |
Clip some lines with the half-space.
Definition at line 61 of file halfspaceD2test.cpp.
References assertreturnOS, halfspaceD2< PT, PD >::clip(), and halfspaceD2< PT, PD >::clipNeg().
Referenced by main().
00062 { 00063 cout << "Testing clipping in half-space D2." << endl; 00064 cout << "Constructing a vertical half-space left of y-axis." << endl; 00065 00066 cout << "Sending lines on left, right and through the y-axis." << endl; 00067 00068 typedef point2<double> pt2; 00069 00070 // Half space defined left of y-axis. 00071 pt2 p0(0.0,0.0); 00072 pt2 p1(0.0,1.0); 00073 halfspaceD2< pt2, double > h1(p0,p1); 00074 00075 // Vertical line 00076 pt2 a(0.0,0.5); 00077 pt2 m(1.0,0.0); 00078 00079 point2<double> t0(.12, .7); 00080 //cout << SHOW(t0) << endl; 00081 assertreturnOS(h1.clip(t0[0],t0[1],a,m)==false); 00082 00083 point2<double> t1(-.12, -.7); 00084 assertreturnOS(h1.clip(t1[0],t1[1],a,m)==true); 00085 00086 point2<double> t2(-3, 4.2); 00087 assertreturnOS(h1.clip(t2[0],t2[1],a,m)==true); 00088 00089 point2<double> t3(-3, 4.2); 00090 assertreturnOS(h1.clipNeg(t3[0],t3[1],a,m)==true); 00091 00092 point2<double> t4(1.3, 4.2); 00093 assertreturnOS(h1.clipNeg(t4[0],t4[1],a,m)==true); 00094 00095 point2<double> t5(-5.3, -2.3); 00096 assertreturnOS(h1.clipNeg(t5[0],t5[1],a,m)==false); 00097 00098 return 0; 00099 }
1.5.8