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 Local3DPoint& p, const LocalError& err, 00021 float scale) const { 00022 if(scale >=0){ 00023 return 00024 fabs(p.z()) < halfThickness && 00025 (fabs(p.x()) < halfWidth || fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00026 (fabs(p.y()) < halfLength || fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00027 }else{ 00028 return 00029 fabs(p.z()) < halfThickness && 00030 (fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00031 (fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00032 } 00033 } 00034 00035 bool RectangularPlaneBounds::inside( const Local2DPoint& p, const LocalError& err, 00036 float scale) const { 00037 if(scale >=0){ 00038 return 00039 (fabs(p.x()) < halfWidth || fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00040 (fabs(p.y()) < halfLength || fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00041 }else{ 00042 return 00043 (fabs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) && 00044 (fabs(p.y()) < halfLength + std::sqrt(err.yy())*scale); 00045 } 00046 } 00047 00048 Bounds* RectangularPlaneBounds::clone() const { 00049 return new RectangularPlaneBounds(*this); 00050 } 00051 00052