CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
Point3D.h
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: Point3D.h,v 1.5 2010/06/16 16:21:27 garren Exp $
3// ---------------------------------------------------------------------------
4//
5// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6//
7// History:
8// 09.09.96 E.Chernyaev - initial version
9// 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
10// the functionality from CLHEP::Hep3Vector
11// 01.04.03 E.Chernyaev - CLHEP-1.9: template version
12//
13
14#ifndef HEP_POINT3D_H
15#define HEP_POINT3D_H
16
17#include <iosfwd>
18#include "CLHEP/Geometry/defs.h"
21
22namespace HepGeom {
23
24 class Transform3D;
25
34 template<class T>
35 class Point3D : public BasicVector3D<T> {};
36
43 template<>
44 class Point3D<float> : public BasicVector3D<float> {
45 public:
48 Point3D() = default;
49
52 Point3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
53
56 explicit Point3D(const float * a)
57 : BasicVector3D<float>(a[0],a[1],a[2]) {}
58
61 Point3D(const Point3D<float> &) = default;
62
65 Point3D(Point3D<float> &&) = default;
66
69 Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
70
73 ~Point3D() = default;
74
78
83 return *this;
84 }
85
89
92 float distance2() const { return mag2(); }
93
96 float distance2(const Point3D<float> & p) const {
97 float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
98 return dx*dx + dy*dy + dz*dz;
99 }
100
103 float distance() const { return std::sqrt(distance2()); }
104
107 float distance(const Point3D<float> & p) const {
108 return std::sqrt(distance2(p));
109 }
110
114 };
115
121 operator*(const Transform3D & m, const Point3D<float> & p);
122
129 template<>
130 class Point3D<double> : public BasicVector3D<double> {
131 public:
134 Point3D() = default;
135
138 Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
139
142 explicit Point3D(const float * a)
143 : BasicVector3D<double>(a[0],a[1],a[2]) {}
144
147 explicit Point3D(const double * a)
148 : BasicVector3D<double>(a[0],a[1],a[2]) {}
149
152 Point3D(const Point3D<double> &) = default;
153
157
160 Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
161
164 Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
165
168 ~Point3D() = default;
169
176 : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
177
183 operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
184
188
193 return *this;
194 }
195
200 return *this;
201 }
202
206
209 double distance2() const { return mag2(); }
210
213 double distance2(const Point3D<double> & p) const {
214 double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
215 return dx*dx + dy*dy + dz*dz;
216 }
217
220 double distance() const { return std::sqrt(distance2()); }
221
224 double distance(const Point3D<double> & p) const {
225 return std::sqrt(distance2(p));
226 }
227
231 };
232
238 operator*(const Transform3D & m, const Point3D<double> & p);
239
240} /* namespace HepGeom */
241
242#ifdef ENABLE_BACKWARDS_COMPATIBILITY
243// backwards compatibility will be enabled ONLY in CLHEP 1.9
244#include "CLHEP/config/CLHEP.h"
247typedef HepGeom::Point3D<double> HepPoint3D;
248#endif
249
250#endif /* HEP_POINT3D_H */
BasicVector3D< T > & operator=(const BasicVector3D< T > &)=default
double distance2() const
Definition Point3D.h:209
Point3D< double > & operator=(Point3D< double > &&)=default
Point3D< float > & operator=(const BasicVector3D< float > &v)
Definition Point3D.h:81
Point3D(const float *a)
Definition Point3D.h:142
double distance() const
Definition Point3D.h:220
Point3D(Point3D< double > &&)=default
double distance2(const Point3D< double > &p) const
Definition Point3D.h:213
float distance2(const Point3D< float > &p) const
Definition Point3D.h:96
Point3D< float > & operator=(Point3D< float > &&)=default
Point3D(float x1, float y1, float z1)
Definition Point3D.h:52
Point3D(const double *a)
Definition Point3D.h:147
float distance2() const
Definition Point3D.h:92
Point3D< float > operator*(const Transform3D &m, const Point3D< float > &p)
Point3D< double > & transform(const Transform3D &m)
Point3D< float > & operator=(const Point3D< float > &)=default
Point3D(const BasicVector3D< float > &v)
Definition Point3D.h:69
double distance(const Point3D< double > &p) const
Definition Point3D.h:224
Point3D(const BasicVector3D< double > &v)
Definition Point3D.h:164
Point3D< double > operator*(const Transform3D &m, const Point3D< double > &p)
Point3D(const float *a)
Definition Point3D.h:56
Point3D(const BasicVector3D< float > &v)
Definition Point3D.h:160
float distance() const
Definition Point3D.h:103
Point3D(const Point3D< double > &)=default
Point3D< float > & transform(const Transform3D &m)
Point3D(double x1, double y1, double z1)
Definition Point3D.h:138
float distance(const Point3D< float > &p) const
Definition Point3D.h:107
Point3D< double > & operator=(const BasicVector3D< double > &v)
Definition Point3D.h:198
Point3D(const Point3D< float > &)=default
Point3D(Point3D< float > &&)=default
Point3D< double > & operator=(const BasicVector3D< float > &v)
Definition Point3D.h:191
Point3D(const CLHEP::Hep3Vector &v)
Definition Point3D.h:175
Point3D< double > & operator=(const Point3D< double > &)=default