00001 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" 00002 #include "DataFormats/GeometrySurface/interface/LocalError.h" 00003 #include <cmath> 00004 00005 RectangularPlaneBounds::RectangularPlaneBounds( float w, float h, float t) : 00006 halfWidth(w), halfLength(h), halfThickness(t) {} 00007 00008 00009 bool RectangularPlaneBounds::inside( const Local2DPoint& p) const { 00010 return fabs(p.x()) <= halfWidth && fabs(p.y()) <= halfLength; 00011 } 00012 00013 bool RectangularPlaneBounds::inside( const Local3DPoint& p) const { 00014 return 00015 fabs(p.x()) < halfWidth && 00016 fabs(p.y()) < halfLength && 00017 fabs(p.z()) < halfThickness; 00018 } 00019 00020 bool RectangularPlaneBounds::inside(const Local2DPoint& p, float tollerance) const { 00021 return std::abs(p.x()) < halfWidth + tollerance && 00022 std::abs(p.y()) < halfLength + tollerance; 00023 00024 } 00025 00026 bool RectangularPlaneBounds::inside(const Local3DPoint& p, const LocalError& err, 00027 float scale) const { 00028 if(scale >=0){ 00029 return 00030 fabs(p.z()) < halfThickness && 00031 (fabs(p.x()) < halfWidth || fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00032 (fabs(p.y()) < halfLength || fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00033 }else{ 00034 return 00035 fabs(p.z()) < halfThickness && 00036 (fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00037 (fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00038 } 00039 } 00040 00041 bool RectangularPlaneBounds::inside( const Local2DPoint& p, const LocalError& err, 00042 float scale) const { 00043 if(scale >=0){ 00044 return 00045 (fabs(p.x()) < halfWidth || fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00046 (fabs(p.y()) < halfLength || fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00047 }else{ 00048 return 00049 (fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00050 (fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00051 } 00052 } 00053 00054 Bounds* RectangularPlaneBounds::clone() const { 00055 return new RectangularPlaneBounds(*this); 00056 } 00057 00058