Files Classes Functions Hierarchy
00001 #ifndef HALFSPACED3INDEXEDFULL_H 00002 #define HALFSPACED3INDEXEDFULL_H 00003 00004 #include <cassert> 00005 using namespace std; 00006 00007 #include <typedefs.h> 00008 #include <partitionspace.h> 00009 #include <mathlib.h> 00010 #include <zero.h> 00011 00018 template< typename PT, typename PD, typename INDX > 00019 class halfspaceD3indexedfull : public partitionspace<PT> 00020 { 00021 public: 00022 00023 PT const * pts; 00024 00026 PT normal; 00027 00029 INDX i0; 00031 INDX i1; 00033 INDX i2; 00034 00038 halfspaceD3indexedfull 00039 ( 00040 PT const * pts_, 00041 INDX i0_, 00042 INDX i1_, 00043 INDX i2_ 00044 ) 00045 : pts(pts_), 00046 i0(i0_), i1(i1_), i2(i2_) 00047 { normalcalculate(); } 00048 00050 void normalcalculate(); 00051 00053 boolc isInside( PT const & x ) const 00054 { return 0 < normal.x*(x.x-pts[i0].x)+normal.y*(x.y-pts[i0].y)+normal.z*(x.z-pts[i0].z); } 00056 boolc isInsideOrOnBoundary( PT const & x ) const 00057 { return 0 < zero<PD>::val+normal.x*(x.x-pts[i0].x)+normal.y*(x.y-pts[i0].y)+normal.z*(x.z-pts[i0].z); } 00058 00062 PD const distancefromhalfspace(PT const & w) const 00063 { 00064 PT p; 00065 p.x=normal.x*normal.x*(pts[i0].x-w.x); 00066 p.y=normal.y*normal.y*(pts[i0].y-w.y); 00067 p.z=normal.z*normal.z*(pts[i0].z-w.z); 00068 return p.x*p.x+p.y*p.y+p.z*p.z; 00069 } 00070 }; 00071 00072 00073 // --------------------------------------------------------- 00074 // Implementation 00075 00076 00077 template< typename PT, typename PD, typename INDX > 00078 void halfspaceD3indexedfull<PT,PD,INDX>::normalcalculate() 00079 { 00080 PT u(pts[i2] - pts[i1]); 00081 PT v(pts[i0] - pts[i1]); 00082 00083 normal.x=u.y*v.z-v.y*u.z; 00084 normal.y=u.z*v.x-u.x*v.z; 00085 normal.z=u.x*v.y-u.y*v.x; 00086 } 00087 00088 00089 #endif 00090 00091
1.5.8