ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Point3D.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Point3D.h
1 // -*- C++ -*-
2 // ---------------------------------------------------------------------------
3 //
4 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
5 //
6 // History:
7 // 09.09.96 E.Chernyaev - initial version
8 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
9 // the functionality from CLHEP::Hep3Vector
10 // 01.04.03 E.Chernyaev - CLHEP-1.9: template version
11 //
12 
13 #ifndef HEP_POINT3D_H
14 #define HEP_POINT3D_H
15 
16 #include <iosfwd>
19 
20 namespace HepGeom {
21 
22  class Transform3D;
23 
32  template<class T>
33  class Point3D : public BasicVector3D<T> {};
34 
41  template<>
42  class Point3D<float> : public BasicVector3D<float> {
43  public:
46  Point3D() = default;
47 
50  Point3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
51 
54  explicit Point3D(const float * a)
55  : BasicVector3D<float>(a[0],a[1],a[2]) {}
56 
59  Point3D(const Point3D<float> &) = default;
60 
63  Point3D(Point3D<float> &&) = default;
64 
67  Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
68 
71  ~Point3D() = default;
72 
75  Point3D<float> & operator=(const Point3D<float> &) = default;
76 
81  return *this;
82  }
83 
86  Point3D<float> & operator=(Point3D<float> &&) = default;
87 
90  float distance2() const { return mag2(); }
91 
94  float distance2(const Point3D<float> & p) const {
95  float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
96  return dx*dx + dy*dy + dz*dz;
97  }
98 
101  float distance() const { return std::sqrt(distance2()); }
102 
105  float distance(const Point3D<float> & p) const {
106  return std::sqrt(distance2(p));
107  }
108 
112  };
113 
118  Point3D<float>
119  operator*(const Transform3D & m, const Point3D<float> & p);
120 
127  template<>
128  class Point3D<double> : public BasicVector3D<double> {
129  public:
132  Point3D() = default;
133 
136  Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
137 
140  explicit Point3D(const float * a)
141  : BasicVector3D<double>(a[0],a[1],a[2]) {}
142 
145  explicit Point3D(const double * a)
146  : BasicVector3D<double>(a[0],a[1],a[2]) {}
147 
150  Point3D(const Point3D<double> &) = default;
151 
154  Point3D(Point3D<double> &&) = default;
155 
158  Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
159 
162  Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
163 
166  ~Point3D() = default;
167 
174  : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
175 
181  operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
182 
185  Point3D<double> & operator=(const Point3D<double> &) = default;
186 
191  return *this;
192  }
193 
198  return *this;
199  }
200 
203  Point3D<double> & operator=(Point3D<double> &&) = default;
204 
207  double distance2() const { return mag2(); }
208 
211  double distance2(const Point3D<double> & p) const {
212  double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
213  return dx*dx + dy*dy + dz*dz;
214  }
215 
218  double distance() const { return std::sqrt(distance2()); }
219 
222  double distance(const Point3D<double> & p) const {
223  return std::sqrt(distance2(p));
224  }
225 
229  };
230 
235  Point3D<double>
236  operator*(const Transform3D & m, const Point3D<double> & p);
237 
238 } /* namespace HepGeom */
239 
240 #endif /* HEP_POINT3D_H */