CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Plane.h
Go to the documentation of this file.
1 #ifndef Geom_Plane_H
2 #define Geom_Plane_H
3 
15 #include "boost/intrusive_ptr.hpp"
16 
17 class Plane : public Surface {
18 public:
19  template<typename... Args>
20  Plane(Args&& ... args) :
21  Surface(std::forward<Args>(args)...){setPosPrec();computeSpan();}
22 
27 
28 
32  template<typename... Args>
33  static PlanePointer build(Args&& ... args) {
34  return PlanePointer(new Plane(std::forward<Args>(args)...));
35  }
36 
37  ~Plane(){}
38 
39 // extension of Surface interface for planes
40 
41  GlobalVector normalVector() const { return GlobalVector(rotation().z()); }
42 
45  float localZ (const GlobalPoint& gp) const {
46  return normalVector().dot(gp-position());
47  }
48 
49  float localZclamped (const GlobalPoint& gp) const {
50  auto d = localZ(gp);
51  return std::abs(d) > posPrec() ? d : 0;
52  }
53 
55  float localZ (const GlobalVector& gv) const {
56  return normalVector().dot(gv);
57  }
58 
59  // precision on position
60  float posPrec() const { return m_posPrec;}
61 
62  void computeSpan() { if(theBounds) theBounds->computeSpan(*this);}
63 
64 
65 // implementation of Surface interface
66 
67  virtual SurfaceOrientation::Side side( const LocalPoint& p, Scalar toler) const final {
68  return (std::abs(p.z())<toler) ? SurfaceOrientation::onSurface :
70  }
71 
72  virtual SurfaceOrientation::Side side( const GlobalPoint& p, Scalar toler) const final {
73  Scalar lz = localZ(p);
74  return (std::abs(lz)<toler ? SurfaceOrientation::onSurface :
76  }
77 
80 
83 
84 private:
85  void setPosPrec() {
87  auto p = position();
88  float l = std::max(std::max(std::abs(p.x()),std::abs(p.y())),std::abs(p.z()));
89  m_posPrec = std::abs(l-::nextafterf(l,maxf)); // LSB (can be multiplied by 4 or divided by 4 for safety depending on usage)
90  }
91 
92  Scalar m_posPrec; // the precision on the actual global position
93 
94 };
95 using BoundPlane = Plane;
96 
97 #endif
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const final
tangent plane to surface from global point
Definition: Plane.cc:6
void computeSpan()
Definition: Plane.h:62
float localZ(const GlobalVector &gv) const
Fast access to component perpendicular to plane for a vector.
Definition: Plane.h:55
ReferenceCountingPointer< Plane > PlanePointer
Definition: Plane.h:23
GlobalVector normalVector() const
Definition: Plane.h:41
Scalar m_posPrec
Definition: Plane.h:92
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
float posPrec() const
Definition: Plane.h:60
Vector3DBase< float, GlobalTag > GlobalVector
Definition: Plane.h:17
#define constexpr
tuple d
Definition: ztail.py:151
void setPosPrec()
Definition: Plane.h:85
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
Plane(Args &&...args)
Definition: Plane.h:20
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float localZclamped(const GlobalPoint &gp) const
Definition: Plane.h:49
string const
Definition: compareJSON.py:14
virtual SurfaceOrientation::Side side(const LocalPoint &p, Scalar toler) const final
Definition: Plane.h:67
extstd::clone_ptr< Bounds > theBounds
Definition: Surface.h:141
const RotationType & rotation() const
const PositionType & position() const
virtual SurfaceOrientation::Side side(const GlobalPoint &p, Scalar toler) const final
Definition: Plane.h:72
~Plane()
Definition: Plane.h:37