Files Classes Functions Hierarchy
#include <linetest.h>
Static Public Member Functions | |
| static void | test01 () |
| Basic line tests. | |
| static void | test02 () |
| Testing minimizing points on two lines in 3D space. | |
| static int | unittest01 () |
Definition at line 7 of file linetest.h.
| void linetest::test01 | ( | ) | [static] |
Basic line tests.
Definition at line 10 of file linetest.cpp.
References delta, point2< T >::distance(), line< PT, PD >::nearestpoint(), line< PT, PD >::nml, line< PT, PD >::normalize(), SHOW, and line< PT, PD >::tD2().
Referenced by main().
00011 { 00012 typedef point2<double> pt2; 00013 typedef point3<double> pt3; 00014 00015 line<pt2,double> L1(pt2(1.0,1.0),pt2()); 00016 00017 cout << "L1: " << (stringc) L1 << endl; 00018 00019 double len=5.0; 00020 cout << "Normalize to having nml with " << len << " length." << endl; 00021 00022 L1.normalize(len); 00023 cout << "L1: " << (stringc) L1 << endl; 00024 00025 cout << SHOW(L1.nml.distance()) << endl; 00026 cout << SHOW( L1(0.0) ) << endl; 00027 cout << SHOW( L1(1.0) ) << endl; 00028 00029 cout << "Re normalize." << endl; 00030 L1.normalize(); 00031 cout << "L1: " << (stringc) L1 << endl; 00032 00033 pt2 p2(6.0,6.0); 00034 cout << SHOW(p2) << endl; 00035 cout << "Find the t value of p2." << endl; 00036 double t1; 00037 bool res; 00038 res = L1.tD2(t1,p2); 00039 cout << SHOW(res) << " " << SHOW(t1) << endl; 00040 cout << SHOW(L1(t1)) << endl; 00041 00042 cout << endl; 00043 cout << "Testing point minimized to a line." << endl; 00044 double delta=0.1; 00045 cout << SHOW(delta) << endl; 00046 pt2 p3(2.0,3.0); 00047 cout << SHOW(p3) << endl; 00048 cout << "Minimize to L1:" << (stringc)L1 << endl; 00049 L1.nearestpoint(t1,p3); 00050 cout << SHOW((L1(t1-delta)-p3).distance()) << endl; 00051 cout << SHOW((L1(t1)-p3).distance()) << endl; 00052 cout << SHOW((L1(t1+delta)-p3).distance()) << endl; 00053 00054 }
| void linetest::test02 | ( | ) | [static] |
Testing minimizing points on two lines in 3D space.
Definition at line 57 of file linetest.cpp.
References delta, line< PT, PD >::lineD3minimized(), pts, and SHOW.
Referenced by main().
00058 { 00059 typedef point3<double> pt3; 00060 00061 pt3 pts[] = 00062 { 00063 pt3(0.0,0.0,0.0), 00064 pt3(1.0,-3.0,2.0), 00065 pt3(.24,.1,-.3), 00066 pt3(-2.0,-10.0,4.3) 00067 }; 00068 00069 line<pt3,double> L1(pts[0],pts[1],true); 00070 line<pt3,double> L2(pts[2],pts[3],true); 00071 00072 double t1; 00073 double t2; 00074 bool res; 00075 res = L1.lineD3minimized(t1,t2,L2); 00076 cout << SHOW(res) << endl; 00077 00078 double delta = 0.1; 00079 cout << SHOW(delta) << endl; 00080 00081 cout << "Varying t1" << endl; 00082 cout << SHOW((L1(t1-delta)-L2(t2)).distance()) << endl; 00083 cout << SHOW((L1(t1)-L2(t2)).distance()) << endl; 00084 cout << SHOW((L1(t1+delta)-L2(t2)).distance()) << endl; 00085 00086 cout << "Varying t2" << endl; 00087 cout << SHOW((L1(t1)-L2(t2-delta)).distance()) << endl; 00088 cout << SHOW((L1(t1)-L2(t2)).distance()) << endl; 00089 cout << SHOW((L1(t1)-L2(t2+delta)).distance()) << endl; 00090 00091 }
| int linetest::unittest01 | ( | ) | [static] |
Definition at line 93 of file linetest.cpp.
References assertreturnOS, line< PT, PD >::intersects(), and SHOW.
Referenced by main().
00094 { 00095 typedef point2<double> pt2; 00096 00097 line<pt2,double> L1(pt2(0.0,0.0),pt2(8.0,0.0),true); 00098 line<pt2,double> L2(pt2(3.0,-5.0),pt2(3.0,5.0),true); 00099 00100 double t0; 00101 double t1; 00102 00103 bool res; 00104 res = L1.intersects(t0,t1,L2); 00105 if (res==false) 00106 return 1; 00107 00108 cout << SHOW( L1(t0) ) << endl; 00109 cout << SHOW( L2(t1) ) << endl; 00110 00111 assertreturnOS( zero<double>::test( (L1(t0)-pt2(3.0,0.0)).dot() ) ); 00112 00113 return 0; 00114 }
1.5.8