Geant4  v4-10.4-release
Point3D.h
이 파일의 문서화 페이지로 가기
1 // -*- C++ -*-
2 // $Id:$
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>
20
21 namespace HepGeom {
22
23  class Transform3D;
24
33  template<class T>
34  class Point3D : public BasicVector3D<T> {};
35
42  template<>
43  class Point3D<float> : public BasicVector3D<float> {
44  public:
47  Point3D() {}
48
51  Point3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
52
55  explicit Point3D(const float * a)
56  : BasicVector3D<float>(a[0],a[1],a[2]) {}
57
60  Point3D(const Point3D<float> & v) : BasicVector3D<float>(v) {}
61
64  Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
65
68  ~Point3D() {}
69
73  set(v.x(),v.y(),v.z()); return *this;
74  }
75
79  set(v.x(),v.y(),v.z()); return *this;
80  }
81
84  float distance2() const { return mag2(); }
85
88  float distance2(const Point3D<float> & p) const {
89  float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
90  return dx*dx + dy*dy + dz*dz;
91  }
92
95  float distance() const { return std::sqrt(distance2()); }
96
99  float distance(const Point3D<float> & p) const {
100  return std::sqrt(distance2(p));
101  }
102
105  Point3D<float> & transform(const Transform3D & m);
106  };
107
112  Point3D<float>
113  operator*(const Transform3D & m, const Point3D<float> & p);
114
121  template<>
122  class Point3D<double> : public BasicVector3D<double> {
123  public:
126  Point3D() {}
127
130  Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
131
134  explicit Point3D(const float * a)
135  : BasicVector3D<double>(a[0],a[1],a[2]) {}
136
139  explicit Point3D(const double * a)
140  : BasicVector3D<double>(a[0],a[1],a[2]) {}
141
144  Point3D(const Point3D<double> & v) : BasicVector3D<double>(v) {}
145
148  Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
149
152  Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
153
156  ~Point3D() {}
157
164  : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
165
171  operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
172
176  set(v.x(),v.y(),v.z()); return *this;
177  }
178
182  set(v.x(),v.y(),v.z()); return *this;
183  }
184
188  set(v.x(),v.y(),v.z()); return *this;
189  }
190
193  double distance2() const { return mag2(); }
194
197  double distance2(const Point3D<double> & p) const {
198  double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
199  return dx*dx + dy*dy + dz*dz;
200  }
201
204  double distance() const { return std::sqrt(distance2()); }
205
208  double distance(const Point3D<double> & p) const {
209  return std::sqrt(distance2(p));
210  }
211
214  Point3D<double> & transform(const Transform3D & m);
215  };
216
221  Point3D<double>
222  operator*(const Transform3D & m, const Point3D<double> & p);
223
224 } /* namespace HepGeom */
225
226 #endif /* HEP_POINT3D_H */
Point3D< double > & operator=(const BasicVector3D< float > &v)
Definition: Point3D.h:181
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
Float_t y1[n_points_granero]
Definition: compare.C:5
float distance2(const Point3D< float > &p) const
Definition: Point3D.h:88
float distance2() const
Definition: Point3D.h:84
Float_t x1[n_points_granero]
Definition: compare.C:5
const char * p
Definition: xmltok.h:285
Point3D< double > & operator=(const BasicVector3D< double > &v)
Definition: Point3D.h:187
Point3D(float x1, float y1, float z1)
Definition: Point3D.h:51
double distance(const Point3D< double > &p) const
Definition: Point3D.h:208
static constexpr double m
Definition: G4SIunits.hh:129
double distance() const
Definition: Point3D.h:204
Point3D(const BasicVector3D< float > &v)
Definition: Point3D.h:148
Point3D< float > & operator=(const Point3D< float > &v)
Definition: Point3D.h:72
Point3D(const BasicVector3D< double > &v)
Definition: Point3D.h:152
float distance(const Point3D< float > &p) const
Definition: Point3D.h:99
Point3D< double > & operator=(const Point3D< double > &v)
Definition: Point3D.h:175
Point3D(const double *a)
Definition: Point3D.h:139
Point3D< float > & operator=(const BasicVector3D< float > &v)
Definition: Point3D.h:78
Point3D(const float *a)
Definition: Point3D.h:55
void set(T x1, T y1, T z1)
Normal3D< float > operator*(const Transform3D &m, const Normal3D< float > &v)
Definition: Normal3D.cc:24
Point3D(const Point3D< double > &v)
Definition: Point3D.h:144
Point3D(const float *a)
Definition: Point3D.h:134
Point3D(double x1, double y1, double z1)
Definition: Point3D.h:130
double distance2(const Point3D< double > &p) const
Definition: Point3D.h:197
double distance2() const
Definition: Point3D.h:193
Point3D(const BasicVector3D< float > &v)
Definition: Point3D.h:64
float distance() const
Definition: Point3D.h:95
Point3D(const CLHEP::Hep3Vector &v)
Definition: Point3D.h:163
Point3D(const Point3D< float > &v)
Definition: Point3D.h:60