Geant4-11
Point3D.h
Go to the documentation of this file.
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
20namespace 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
76
81 return *this;
82 }
83
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
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
186
191 return *this;
192 }
193
198 return *this;
199 }
200
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 */
static constexpr double m
Definition: G4SIunits.hh:109
BasicVector3D< T > & operator=(const BasicVector3D< T > &)=default
double distance2() const
Definition: Point3D.h:207
Point3D< double > & operator=(Point3D< double > &&)=default
Point3D(const float *a)
Definition: Point3D.h:140
double distance() const
Definition: Point3D.h:218
Point3D(Point3D< double > &&)=default
double distance2(const Point3D< double > &p) const
Definition: Point3D.h:211
Point3D(const double *a)
Definition: Point3D.h:145
double distance(const Point3D< double > &p) const
Definition: Point3D.h:222
Point3D(const BasicVector3D< double > &v)
Definition: Point3D.h:162
Point3D(const BasicVector3D< float > &v)
Definition: Point3D.h:158
Point3D(const Point3D< double > &)=default
Point3D(double x1, double y1, double z1)
Definition: Point3D.h:136
Point3D< double > & operator=(const BasicVector3D< double > &v)
Definition: Point3D.h:196
Point3D< double > & operator=(const BasicVector3D< float > &v)
Definition: Point3D.h:189
Point3D(const CLHEP::Hep3Vector &v)
Definition: Point3D.h:173
Point3D< double > & operator=(const Point3D< double > &)=default
Point3D< float > & operator=(const BasicVector3D< float > &v)
Definition: Point3D.h:79
float distance2(const Point3D< float > &p) const
Definition: Point3D.h:94
Point3D< float > & operator=(Point3D< float > &&)=default
Point3D(float x1, float y1, float z1)
Definition: Point3D.h:50
float distance2() const
Definition: Point3D.h:90
Point3D< float > & operator=(const Point3D< float > &)=default
Point3D(const BasicVector3D< float > &v)
Definition: Point3D.h:67
Point3D(const float *a)
Definition: Point3D.h:54
float distance() const
Definition: Point3D.h:101
float distance(const Point3D< float > &p) const
Definition: Point3D.h:105
Point3D(const Point3D< float > &)=default
Point3D(Point3D< float > &&)=default
G4bool transform(G4String &input, const G4String &type)
Normal3D< float > operator*(const Transform3D &m, const Normal3D< float > &v)
Definition: Normal3D.cc:23