vtf-logo

Plane.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_Plane_h__)
00009 #define __geom_Plane_h__
00010 
00011 // If we are debugging the whole geom namespace.
00012 #if defined(DEBUG_geom) && !defined(DEBUG_Plane)
00013 #define DEBUG_Plane
00014 #endif
00015 
00016 #include "Point.h"
00017 
00018 #include <cmath>
00019 
00020 BEGIN_NAMESPACE_GEOM
00021 
00023 
00026 template<typename T = double>
00027 class Plane {
00028   //
00029   // Public types.
00030   //
00031 
00032 public:
00033 
00035   typedef T Number;
00037   typedef ads::FixedArray<3,T> Point;
00038     
00039 private:
00040 
00041   Point _point, _normal;
00042   
00043 public:
00044 
00045   //--------------------------------------------------------------------------
00047   // @{
00048 
00050   Plane();
00051 
00053   Plane(const Point& point, const Point& normal);
00054 
00056   Plane(const Point& a, const Point& b, const Point& c);
00057 
00059   void
00060   make(const Point& a, const Point& b, const Point& c);
00061   
00063   Plane(const Plane<T>& other);
00064 
00066   Plane& 
00067   operator=(const Plane& other);
00068 
00070   ~Plane() 
00071   {}
00072 
00073   //  int make (const Point& a, const Point& b, const Point& c);
00074 
00075   // @}  
00076   //--------------------------------------------------------------------------
00078   // @{
00079 
00081   const Point& 
00082   getPointOn() const { 
00083     return _point; 
00084   }
00085 
00087   const Point& 
00088   getNormal() const { 
00089     return _normal; 
00090   }
00091 
00092   // @}  
00093   //--------------------------------------------------------------------------
00095   // @{
00096 
00097   // CONTINUE
00098 #if 0
00100   Point& 
00101   point() 
00102   { 
00103     return _point; 
00104   }
00105 
00107   Point& 
00108   normal() 
00109   { 
00110     return _normal; 
00111   }
00112 #endif
00113 
00114   // @}  
00115   //--------------------------------------------------------------------------
00117   // @{
00118 
00120   bool 
00121   isValid() const;
00122 
00123   // @}  
00124   //--------------------------------------------------------------------------
00126   // @{
00127 
00129   Plane& 
00130   operator+=(const Point& p) {
00131     _point += p;
00132     return *this;
00133   }
00134 
00136   Plane& 
00137   operator-=(const Point& p) {
00138     _point -= p;
00139     return *this;
00140   }
00141 
00142   // @}  
00143   //--------------------------------------------------------------------------
00145   // @{
00146 
00148   T 
00149   computeSignedDistance(const Point& p) const;
00150 
00152   T 
00153   computeSignedDistanceAndClosestPoint(const Point& x, 
00154                                        Point* closestPoint) const;
00155 
00156   // @}
00157 };
00158 
00159 
00160 //
00161 // Unary Operators
00162 //
00163 
00164 
00166 
00167 template<typename T>
00168 inline
00169 const Plane<T>&
00170 operator+(const Plane<T>& x) {
00171   return x;
00172 }
00173 
00174 
00176 
00177 template<typename T>
00178 inline
00179 Plane<T> 
00180 operator-(const Plane<T>& x) {
00181   return Plane<T>(x.getPointOn(), - x.getNormal());
00182 }
00183 
00184 
00185 //
00186 // Equality Operators
00187 //
00188 
00189 
00191 
00192 template<typename T>
00193 inline
00194 bool 
00195 operator==(const Plane<T>& x, const Plane<T>& y) { 
00196   return (x.getPointOn() == y.getPointOn() && 
00197           x.getNormal() == y.getNormal()); 
00198 }
00199 
00200 
00202 
00203 template<typename T>
00204 inline
00205 bool 
00206 operator!=(const Plane<T>& x, const Plane<T>& y) { 
00207   return !(x == y); 
00208 }
00209 
00210 
00211 //
00212 // File I/O
00213 //
00214 
00215 
00217 
00218 template<typename T>
00219 std::istream& 
00220 operator>>(std::istream& in, Plane<T>& x);
00221 
00222 
00224 
00225 template<typename T>
00226 std::ostream& 
00227 operator<<(std::ostream& out, const Plane<T>& x);
00228 
00229 
00230 END_NAMESPACE_GEOM
00231 
00232 #define __geom_Plane_ipp__
00233 #include "Plane.ipp"
00234 #undef __geom_Plane_ipp__
00235 
00236 #endif

Generated on Fri Aug 24 12:55:56 2007 for Computational Geometry Package by  doxygen 1.4.7