00001 #ifndef FourPointPlaneBounds_H 00002 #define FourPointPlaneBounds_H 00003 00004 #include "DataFormats/GeometrySurface/interface/Bounds.h" 00005 #include "DataFormats/GeometryVector/interface/LocalVector.h" 00006 #include "DataFormats/GeometryVector/interface/Vector2DBase.h" 00007 00008 typedef Vector2DBase< float, LocalTag> Local2DVector; 00009 00010 class FourPointPlaneBounds : public Bounds { 00011 public: 00012 00013 typedef LocalPoint::ScalarType Scalar; 00014 00017 FourPointPlaneBounds( const LocalPoint& a, const LocalPoint& b, 00018 const LocalPoint& c, const LocalPoint& d); 00019 ~FourPointPlaneBounds() {} 00020 00021 virtual float length() const; 00022 virtual float width() const; 00023 virtual float thickness() const; 00024 00025 // basic bounds function 00026 virtual bool inside( const Local3DPoint& lp) const; 00027 00028 virtual bool inside( const Local3DPoint& lp , const LocalError& e, float scale) const { 00029 return inside( lp); 00030 } 00031 00032 virtual Bounds* clone() const {return new FourPointPlaneBounds(*this);} 00033 00034 private: 00035 00036 Local2DPoint corners_[4]; 00037 00038 const Local2DPoint& corner(int i) const {return corners_[i%4];} 00039 double checkSide( int i, const Local2DPoint& lp) const; 00040 00041 double checkSide( int i, Scalar x, Scalar y) const { 00042 const Local2DPoint& cor( corner(i)); 00043 Local2DVector v( corner(i+1) - cor); 00044 // Local2DVector normal( -v.y(), v.x()); // 90 deg rotated 00045 return -v.y() * (x-cor.x()) + v.x() * (y-cor.y()); // == normal.dot(LP(x,y)-cor)) 00046 } 00047 00048 }; 00049 00050 #endif