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
0022
0023
0024
0025
0026 GlobalVector yPlane(rotation().z());
0027
0028
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
0034
0035
0036 return ConstReferenceCountingPointer<TangentPlane>(new TangentPlane(aPoint, RotationType(xPlane, yPlane)));
0037 }