Files Classes Functions Hierarchy
#include <planetest.h>
Static Public Member Functions | |
| static void | test01 (int argc, char **argv) |
| Construct a plane through three points. | |
| static void | test02 (int argc, char **argv) |
| Intersection of two planes. | |
| static void | test03 (int argc, char **argv) |
| Given input file with planes write output file with intersecting line. | |
Definition at line 8 of file planetest.h.
| void planetest::test01 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Construct a plane through three points.
Definition at line 11 of file planetest.cpp.
References commandline::mapvar(), SHOW, point3< T >::x, point3< T >::y, and point3< T >::z.
Referenced by main().
00012 { 00013 00014 point3<double> p0(1.0,0.0,0.0); 00015 point3<double> p1(2.0,-3.0,1.0); 00016 point3<double> p2(0.0,-2.0,0.0); 00017 00018 commandline cmd(argc,argv); 00019 00020 cmd.mapvar(p0.x,"p0.x"); 00021 cmd.mapvar(p0.y,"p0.y"); 00022 cmd.mapvar(p0.z,"p0.z"); 00023 cmd.mapvar(p1.x,"p1.x"); 00024 cmd.mapvar(p1.y,"p1.y"); 00025 cmd.mapvar(p1.z,"p1.z"); 00026 cmd.mapvar(p2.x,"p2.x"); 00027 cmd.mapvar(p2.y,"p2.y"); 00028 cmd.mapvar(p2.z,"p2.z"); 00029 00030 cout << SHOW(p0) << endl; 00031 cout << SHOW(p1) << endl; 00032 cout << SHOW(p2) << endl; 00033 00034 bool valid; 00035 plane p(valid,p0,p1,p2); 00036 00037 cout << SHOW(valid) << endl; 00038 00039 cout << (string)p << endl; 00040 00041 }
| void planetest::test02 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Intersection of two planes.
Definition at line 43 of file planetest.cpp.
References plane::intersects(), plane::isPointOnPlane(), and SHOW.
Referenced by main().
00044 { 00045 cout << "Solve Plane to Plane Intersection." << endl; 00046 00047 plane P1( point3<double>(0.0,0.0,1.0), 1.0 ); 00048 plane P2( point3<double>(0.0,1.0,0.0), 0.0 ); 00049 00050 cout << "P1: " << (string)P1 << endl; 00051 cout << "P2: " << (string)P2 << endl; 00052 00053 point3<double> A; 00054 point3<double> B; 00055 00056 cout << SHOW(P1.intersects(A,B,P2)) << endl; 00057 cout << SHOW(A) << endl; 00058 cout << SHOW(B) << endl; 00059 cout << "(" << A << ") + (" << B << ")t" << endl; 00060 00061 cout << "Is a point on the line also on the plane?" << endl; 00062 cout << "Enter t: "; 00063 double t; 00064 cin >> t; 00065 point3<double> p = A + B*t; 00066 cout << SHOW(p) << endl; 00067 cout << SHOW(P1.isPointOnPlane(p)) <<endl; 00068 cout << SHOW(P2.isPointOnPlane(p)) <<endl; 00069 }
| void planetest::test03 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Given input file with planes write output file with intersecting line.
Example
$./main ... in=file1.txt out=file2.txt
File Format
Input file
P1.x P1.y P1.z P1.d
P2.x P2.y P2.z P2.d
Output file
0 or 1
A.x A.y A.z
B.x B.y B.z
Definition at line 71 of file planetest.cpp.
References plane::intersects(), plane::isPointOnPlane(), commandline::mapvar(), SHOW, point3< T >::x, point3< T >::y, and point3< T >::z.
Referenced by main().
00072 { 00073 commandline cmd(argc,argv); 00074 00075 string in; 00076 string out; 00077 00078 cmd.mapvar(in,"in"); 00079 if (in.empty()) 00080 { 00081 cout << "error: in=filename1 out=filename2 expected" << endl; 00082 return; 00083 } 00084 00085 ifstream filein(in.c_str()); 00086 assert(filein.good()==true); 00087 if (filein.good()==false) 00088 return; 00089 00090 /* 00091 ofstream fileout(out.c_str()); 00092 assert(fileout.good()==true); 00093 if (fileout.good()==false) 00094 return; 00095 */ 00096 00097 point3<double> nml; 00098 double d; 00099 00100 filein >> nml.x; 00101 filein >> nml.y; 00102 filein >> nml.z; 00103 filein >> d; 00104 00105 plane P1(nml,d); 00106 00107 filein >> nml.x; 00108 filein >> nml.y; 00109 filein >> nml.z; 00110 filein >> d; 00111 00112 plane P2(nml,d); 00113 00114 //cout << SHOW(nml) << endl; 00115 //cout << SHOW(d) << endl; 00116 00117 point3<double> A; 00118 point3<double> B; 00119 00120 cout << "P1: " << (stringc)P1 << endl; 00121 cout << "P2: " << (stringc)P2 << endl; 00122 00123 bool res = P1.intersects(A,B,P2); 00124 cout << SHOW(res) << endl; 00125 00126 cout << "(" << A << ") + (" << B << ")t" << endl; 00127 00128 cout << SHOW(A) << endl; 00129 cout << SHOW(A+B) << endl; 00130 cout << SHOW(P1.isPointOnPlane(A)) << endl; 00131 cout << SHOW(P1.isPointOnPlane(A+B)) << endl; 00132 cout << SHOW(P2.isPointOnPlane(A)) << endl; 00133 cout << SHOW(P2.isPointOnPlane(A+B)) << endl; 00134 00135 00136 00137 /* 00138 if (res==true) 00139 { 00140 fileout << "1" << endl; 00141 fileout << A << endl; 00142 fileout << B << endl; 00143 } 00144 else 00145 { 00146 fileout << "0" << endl; 00147 } 00148 */ 00149 00150 }
1.5.8