CMS 3D CMS Logo

Plane.h
Go to the documentation of this file.
1 #ifndef Geom_Plane_H
2 #define Geom_Plane_H
3 
15 
16 class Plane : public Surface {
17 public:
18  template <typename... Args>
19  Plane(Args&&... args) : Surface(std::forward<Args>(args)...) {
20  setPosPrec();
21  computeSpan();
22  }
23 
28 
32  template <typename... Args>
33  static PlanePointer build(Args&&... args) {
34  return PlanePointer(new Plane(std::forward<Args>(args)...));
35  }
36 
37  ~Plane() override {}
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 { return normalVector().dot(gp - position()); }
46 
47  float localZclamped(const GlobalPoint& gp) const {
48  auto d = localZ(gp);
49  return std::abs(d) > posPrec() ? d : 0;
50  }
51 
53  float localZ(const GlobalVector& gv) const { return normalVector().dot(gv); }
54 
55  // precision on position
56  float posPrec() const { return m_posPrec; }
57 
58  void computeSpan() {
59  if (theBounds)
60  theBounds->computeSpan(*this);
61  }
62 
63  // implementation of Surface interface
64 
65  SurfaceOrientation::Side side(const LocalPoint& p, Scalar toler) const final {
66  return (std::abs(p.z()) < toler)
69  }
70 
71  SurfaceOrientation::Side side(const GlobalPoint& p, Scalar toler) const final {
72  Scalar lz = localZ(p);
73  return (std::abs(lz) < toler ? SurfaceOrientation::onSurface
75  }
76 
79 
82 
83 private:
84  void setPosPrec() {
86  auto p = position();
87  float l = std::max(std::max(std::abs(p.x()), std::abs(p.y())), std::abs(p.z()));
89  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 using BoundPlane = Plane;
95 
96 #endif
ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const final
tangent plane to surface from global point
Definition: Plane.cc:4
void computeSpan()
Definition: Plane.h:58
ReferenceCountingPointer< Plane > PlanePointer
Definition: Plane.h:24
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
Scalar m_posPrec
Definition: Plane.h:92
Vector3DBase< float, GlobalTag > GlobalVector
Definition: Plane.h:16
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
void setPosPrec()
Definition: Plane.h:84
SurfaceOrientation::Side side(const LocalPoint &p, Scalar toler) const final
Definition: Plane.h:65
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
float localZ(const GlobalVector &gv) const
Fast access to component perpendicular to plane for a vector.
Definition: Plane.h:53
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
const PositionType & position() const
float posPrec() const
Definition: Plane.h:56
Plane(Args &&... args)
Definition: Plane.h:19
~Plane() override
Definition: Plane.h:37
extstd::clone_ptr< Bounds > theBounds
Definition: Surface.h:107
float localZclamped(const GlobalPoint &gp) const
Definition: Plane.h:47
GlobalVector normalVector() const
Definition: Plane.h:41
const RotationType & rotation() const
SurfaceOrientation::Side side(const GlobalPoint &p, Scalar toler) const final
Definition: Plane.h:71