proj home

Files   Classes   Functions   Hierarchy  

plane.cpp

Go to the documentation of this file.
00001 
00002 #include <sstream>
00003 using namespace std;
00004 
00005 #include <mathlib.h>
00006 #include <plane.h>
00007 
00008 
00009 
00010 plane::plane
00011 (
00012   bool & valid,
00013   point3<double> const & p0,
00014   point3<double> const & p1,
00015   point3<double> const & p2
00016 )
00017 {
00018   valid=false;
00019   point3<double> arm1(p1-p0);
00020   point3<double> arm2(p2-p0);
00021 
00022   // If the points are colinear then the plane can not
00023   // be determined.
00024   crossproduct::evalxyz(nml,arm1,arm2);
00025   if (nml.x*nml.x+nml.y*nml.y+nml.z*nml.z<zero<double>::val)
00026     return;
00027 
00028   valid=true;
00029 
00030   d0 = nml.dot(p0);
00031 }
00032 
00033 
00034 boolc plane::intersects
00035 ( 
00036   point3<double> & A,
00037   point3<double> & B,
00038   plane const & P2 
00039 ) const
00040 {
00041   //crossprod< point3<double> > cp;
00042   //cp(B,nml,P2.nml);
00043   crossproduct::evalxyz(B,nml,P2.nml);
00044   if (zero<double>::test(B.dot(B)))
00045     return false;
00046 
00047   point3<double> w;
00048   bool res;
00049   res = solverInconsistent<double>::d2linearequ
00050   (
00051     A.x, A.y, A.z,
00052     nml.x, nml.y, nml.z, d0,
00053     P2.nml.x, P2.nml.y, P2.nml.z, P2.d0
00054   );
00055 
00056   return res;
00057 
00058 //  if (B.dot(B)<zero<double>::val)
00059 //    return false;
00060 
00061   // Find an intersection point.
00062 
00063 /*
00064   if (nmlxIsZero())
00065     if (P2.nmlxIsZero())
00066     {
00067       A.x = 0.0;
00068     
00069       return solver<double>::d2linearequ
00070       (
00071         A.y,
00072         A.z,
00073         nml.y,
00074         nml.z,
00075         P2.nml.y,
00076         P2.nml.z,
00077         d0,
00078         P2.d0
00079       );
00080     }
00081 
00082   //if (abs(nml.y)+abs(P2.nml.y) < zero )
00083   if (nmlyIsZero())
00084     if (P2.nmlyIsZero())
00085     {
00086       A.y = 0.0;
00087     
00088       return solver<double>::d2linearequ
00089       (
00090         A.x,
00091         A.z,
00092         nml.x,
00093         nml.z,
00094         P2.nml.x,
00095         P2.nml.z,
00096         d0,
00097         P2.d0
00098       );
00099     }
00100 
00101   if (nmlzIsZero())
00102     if (P2.nmlzIsZero())
00103     {
00104       A.z = 0.0;
00105     
00106       return solver<double>::d2linearequ
00107       (
00108         A.x,
00109         A.y,
00110         nml.x,
00111         nml.y,
00112         P2.nml.x,
00113         P2.nml.y,
00114         d0,
00115         P2.d0
00116       );
00117     }
00118 
00119   A.z=1.0;
00120   return solver<double>::d2linearequ
00121   (
00122     A.x,
00123     A.y,
00124     nml.x,
00125     nml.y,
00126     P2.nml.x,
00127     P2.nml.y,
00128     d0-nml.z,
00129     P2.d0-P2.nml.z
00130   );
00131 */
00132 }
00133 
00134 
00135 plane::operator string const () const
00136 {
00137   stringstream ss;
00138   ss << nml.x << " " << nml.y << " " << nml.z << " " << d0;
00139 
00140   return ss.str();
00141 }
00142 
00143 

Generated on Fri Mar 4 00:49:28 2011 for Chelton Evans Source by  doxygen 1.5.8