Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:14

0001 
0002 
0003 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0004 #include "DataFormats/GeometrySurface/interface/TangentPlane.h"
0005 #include "DataFormats/GeometrySurface/interface/GeomExceptions.h"
0006 
0007 #include <cfloat>
0008 
0009 Surface::Side Cylinder::side(const LocalPoint& p, Scalar toler) const {
0010   Scalar lz = p.perp() - radius();
0011   return (fabs(lz) < toler ? SurfaceOrientation::onSurface
0012                            : (lz > 0 ? SurfaceOrientation::positiveSide : SurfaceOrientation::negativeSide));
0013 }
0014 
0015 ConstReferenceCountingPointer<TangentPlane> Cylinder::tangentPlane(const LocalPoint& aPoint) const {
0016   return tangentPlane(toGlobal(aPoint));
0017 }
0018 
0019 ConstReferenceCountingPointer<TangentPlane> Cylinder::tangentPlane(const GlobalPoint& aPoint) const {
0020   //
0021   // Tangent plane at specified point. In order to avoid
0022   // possible numerical problems currently no attempt is made
0023   // to verify, if the point is actually on the cylinder.
0024   //
0025   // local y parallel to axis
0026   GlobalVector yPlane(rotation().z());
0027   // local x normal to y and a vector linking the specified
0028   // point with the axis
0029   GlobalVector xPlane(yPlane.cross(aPoint - position()));
0030   Scalar size = std::max(std::max(std::abs(xPlane.x()), std::abs(xPlane.y())), std::abs(xPlane.z()));
0031   if (size < FLT_MIN)
0032     throw GeometryError("Attempt to construct TangentPlane on cylinder axis");
0033   //   // local z defined by x and y (should point outwards from axis)
0034   //   GlobalVector zPlane(xPlane.cross(yPlane));
0035   // rotation constructor will normalize...
0036   return ConstReferenceCountingPointer<TangentPlane>(new TangentPlane(aPoint, RotationType(xPlane, yPlane)));
0037 }