CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DataFormats/GeometrySurface/src/Cylinder.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00004 #include "DataFormats/GeometrySurface/interface/TangentPlane.h"
00005 #include "DataFormats/GeometrySurface/interface/GeomExceptions.h"
00006 
00007 #include <cfloat>
00008 
00009 Surface::Side Cylinder::side( const LocalPoint& p, Scalar toler) const
00010 {
00011   Scalar lz = p.perp() - radius();
00012   return (fabs(lz)<toler ? SurfaceOrientation::onSurface : 
00013           (lz>0 ? SurfaceOrientation::positiveSide : SurfaceOrientation::negativeSide));
00014 }
00015 
00016 ReferenceCountingPointer<TangentPlane> 
00017 Cylinder::tangentPlane (const LocalPoint& aPoint) const
00018 {
00019   return tangentPlane(toGlobal(aPoint));
00020 }
00021 
00022 ReferenceCountingPointer<TangentPlane> 
00023 Cylinder::tangentPlane (const GlobalPoint& aPoint) const
00024 {
00025   //
00026   // Tangent plane at specified point. In order to avoid
00027   // possible numerical problems currently no attempt is made 
00028   // to verify, if the point is actually on the cylinder.
00029   //
00030   // local y parallel to axis
00031   GlobalVector yPlane(rotation().z());
00032   // local x normal to y and a vector linking the specified
00033   // point with the axis
00034   GlobalVector xPlane(yPlane.cross(aPoint-position()));
00035   Scalar size = std::max(std::max(std::abs(xPlane.x()),std::abs(xPlane.y())), std::abs(xPlane.z()));
00036   if ( size<FLT_MIN ) 
00037     throw GeometryError("Attempt to construct TangentPlane on cylinder axis");
00038 //   // local z defined by x and y (should point outwards from axis)
00039 //   GlobalVector zPlane(xPlane.cross(yPlane));
00040   // rotation constructor will normalize...
00041   return ReferenceCountingPointer<TangentPlane>(new TangentPlane(aPoint,
00042                                                                  RotationType(xPlane,
00043                                                                               yPlane),
00044                                                                  this));
00045 }