00001 // $Header: /nfs/slac/g/glast/ground/cvs/geometry/geometry/Plane.h,v 1.3 2000/01/18 00:42:07 burnett Exp $ 00002 // 00003 // 00004 // 00005 00006 #ifndef __PLANE_H 00007 #define __PLANE_H 00008 #include "geometry/Surface.h" 00015 class Plane: public Surface 00016 { 00017 public: 00022 Plane( const Point& origin, const Vector& n ); 00023 Plane( const Point& origin, const Vector& nhat, double dist ); 00024 00025 00027 virtual double how_near( const Point& x ) const; 00028 virtual double distance( const Point& x, const Vector& v, int inout)const; 00029 00031 virtual Vector normal( const Point& x )const; 00032 00034 virtual void reverse(); 00035 00037 virtual Surface& copy()const; 00038 00039 virtual void setOffset(double offset){ m_d=offset; }; 00040 virtual double offset()const{return m_d;}; 00041 // distance from origin to the plane 00042 00043 00044 const char *nameOf() const { return "Plane"; } 00045 void printOn( std::ostream& os = std::cout ) const; 00046 00047 00048 private: 00049 double m_d; // offset from origin to surface 00050 00051 }; 00052 00053 00054 inline double Plane::how_near( const Point& x ) const 00055 { // Distance from the point x to the infinite Plane. 00056 // The distance will be positive if the point is inside the Plane, 00057 // negative if the point is outside. 00058 return ( m_d + origin()*direction() - x*direction() ); 00059 00060 } 00061 00062 #endif 00063
1.2.3 written by Dimitri van Heesch,
© 1997-2000