CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

CLHEP/Geometry/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"
19 #include "CLHEP/Vector/ThreeVector.h"
21 
22 namespace 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() {}
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> & v) : BasicVector3D<float>(v) {}
62 
66 
69  ~Point3D() {}
70 
74  set(v.x(),v.y(),v.z()); return *this;
75  }
76 
80  set(v.x(),v.y(),v.z()); return *this;
81  }
82 
85  float distance2() const { return mag2(); }
86 
89  float distance2(const Point3D<float> & p) const {
90  float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
91  return dx*dx + dy*dy + dz*dz;
92  }
93 
96  float distance() const { return std::sqrt(distance2()); }
97 
100  float distance(const Point3D<float> & p) const {
101  return std::sqrt(distance2(p));
102  }
103 
106  Point3D<float> & transform(const Transform3D & m);
107  };
108 
113  Point3D<float>
114  operator*(const Transform3D & m, const Point3D<float> & p);
115 
122  template<>
123  class Point3D<double> : public BasicVector3D<double> {
124  public:
127  Point3D() {}
128 
131  Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
132 
135  explicit Point3D(const float * a)
136  : BasicVector3D<double>(a[0],a[1],a[2]) {}
137 
140  explicit Point3D(const double * a)
141  : BasicVector3D<double>(a[0],a[1],a[2]) {}
142 
146 
150 
154 
157  ~Point3D() {}
158 
165  : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
166 
172  operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
173 
177  set(v.x(),v.y(),v.z()); return *this;
178  }
179 
183  set(v.x(),v.y(),v.z()); return *this;
184  }
185 
189  set(v.x(),v.y(),v.z()); return *this;
190  }
191 
194  double distance2() const { return mag2(); }
195 
198  double distance2(const Point3D<double> & p) const {
199  double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
200  return dx*dx + dy*dy + dz*dz;
201  }
202 
205  double distance() const { return std::sqrt(distance2()); }
206 
209  double distance(const Point3D<double> & p) const {
210  return std::sqrt(distance2(p));
211  }
212 
215  Point3D<double> & transform(const Transform3D & m);
216  };
217 
222  Point3D<double>
223  operator*(const Transform3D & m, const Point3D<double> & p);
224 
225 } /* namespace HepGeom */
226 
227 
228 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
229 // backwards compatibility will be enabled ONLY in CLHEP 1.9
230 #include "CLHEP/config/CLHEP.h"
231 #include "CLHEP/Geometry/Normal3D.h"
234 #endif
235 
236 #endif /* HEP_POINT3D_H */
HepGeom::Point3D< double >::distance
double distance(const Point3D< double > &p) const
Definition: CLHEP/Geometry/Point3D.h:209
HepGeom::Point3D< float >::Point3D
Point3D(const float *a)
Definition: CLHEP/Geometry/Point3D.h:56
HepGeom::Point3D< double >::distance
double distance() const
Definition: CLHEP/Geometry/Point3D.h:205
double
#define double(obj)
Definition: excDblThrow.cc:32
HepGeom::Point3D< float >
Definition: CLHEP/Geometry/Point3D.h:44
HepGeom::Point3D< double >::Point3D
Point3D(const BasicVector3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:149
HepGeom::Point3D< double >::Point3D
Point3D()
Definition: CLHEP/Geometry/Point3D.h:127
HepGeom::Point3D< float >::operator=
Point3D< float > & operator=(const BasicVector3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:79
a
@ a
Definition: testCategories.cc:125
Normal3D.h
HepGeom::Point3D< double >::distance2
double distance2() const
Definition: CLHEP/Geometry/Point3D.h:194
HepGeom::Point3D< double >
Definition: CLHEP/Geometry/Point3D.h:123
HepGeom::BasicVector3D
Definition: CLHEP/Geometry/BasicVector3D.h:28
HepGeom::BasicVector3D::y
T y() const
Definition: CLHEP/Geometry/BasicVector3D.h:145
HepGeom::Point3D< double >::~Point3D
~Point3D()
Definition: CLHEP/Geometry/Point3D.h:157
HepGeom::Point3D< double >::Point3D
Point3D(const double *a)
Definition: CLHEP/Geometry/Point3D.h:140
HepGeom::Point3D< float >::distance
float distance(const Point3D< float > &p) const
Definition: CLHEP/Geometry/Point3D.h:100
BasicVector3D.h
HepGeom::Point3D< float >::distance2
float distance2() const
Definition: CLHEP/Geometry/Point3D.h:85
HepGeom::Point3D< double >::operator=
Point3D< double > & operator=(const Point3D< double > &v)
Definition: CLHEP/Geometry/Point3D.h:176
HepGeom::BasicVector3D::z
T z() const
Definition: CLHEP/Geometry/BasicVector3D.h:148
HepGeom::Point3D< double >::Point3D
Point3D(const float *a)
Definition: CLHEP/Geometry/Point3D.h:135
HepPoint3D
HepGeom::Point3D< double > HepPoint3D
Definition: testBug6740.cc:9
HepGeom::Point3D< float >::~Point3D
~Point3D()
Definition: CLHEP/Geometry/Point3D.h:69
HepGeom::Point3D< float >::Point3D
Point3D(const Point3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:61
HepGeom::Point3D< double >::distance2
double distance2(const Point3D< double > &p) const
Definition: CLHEP/Geometry/Point3D.h:198
HepGeom::BasicVector3D::mag2
T mag2() const
Definition: CLHEP/Geometry/BasicVector3D.h:193
HepGeom::Point3D< double >::operator=
Point3D< double > & operator=(const BasicVector3D< double > &v)
Definition: CLHEP/Geometry/Point3D.h:188
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
HepGeom::Point3D< double >::Point3D
Point3D(const Point3D< double > &v)
Definition: CLHEP/Geometry/Point3D.h:145
HepGeom::Point3D< float >::distance
float distance() const
Definition: CLHEP/Geometry/Point3D.h:96
Hep3Vector
Issues Concerning the PhysicsVectors CLHEP Vector Merge The merge of ZOOM PhysicsVdectors and the CLHEP Vector package is completed The purpose of this document is to list the major issues that affected the merge of these and where relevant describe the resolutions More detailed documents describe more minor issues General Approach As agreed at the June CLHEP the approach is to combine the features of each ZOOM class with the corresponding CLHEP class expanding the interface to create a single lingua franca of what a Hep3Vector(for example) means. We are not forming SpaceVector as an class derived from Hep3Vector and enhancing it in that way. Another rule imposed by the agreement is to avoid using the Exceptions package(even though that will later go into CLHEP for other uses). A desirable goal is to avoid cluttering the interface and enlarging the code linked in when ordinary CLHEP Vector functionallity is used. To this end
HepGeom::Point3D< float >::operator=
Point3D< float > & operator=(const Point3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:73
HepGeom::Point3D< double >::Point3D
Point3D(double x1, double y1, double z1)
Definition: CLHEP/Geometry/Point3D.h:131
HepGeom::Transform3D
Definition: CLHEP/Geometry/Transform3D.h:172
CLHEP::Hep3Vector
Definition: Geometry/CLHEP/Vector/ThreeVector.h:41
HepGeom::Point3D< double >::Point3D
Point3D(const CLHEP::Hep3Vector &v)
Definition: CLHEP/Geometry/Point3D.h:164
HepGeom::Point3D< float >::Point3D
Point3D(const BasicVector3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:65
Transform3D.h
HepGeom::BasicVector3D::set
void set(T x1, T y1, T z1)
Definition: CLHEP/Geometry/BasicVector3D.h:162
HepGeom::Point3D< double >::operator=
Point3D< double > & operator=(const BasicVector3D< float > &v)
Definition: CLHEP/Geometry/Point3D.h:182
HepGeom::Point3D< float >::distance2
float distance2(const Point3D< float > &p) const
Definition: CLHEP/Geometry/Point3D.h:89
HepGeom
Definition: CLHEP/Geometry/BasicVector3D.h:19
HepGeom::Point3D
Definition: CLHEP/Geometry/Point3D.h:35
defs.h
HepGeom::BasicVector3D::x
T x() const
Definition: CLHEP/Geometry/BasicVector3D.h:142
HepGeom::Point3D< float >::Point3D
Point3D()
Definition: CLHEP/Geometry/Point3D.h:48
HepGeom::Point3D< float >::Point3D
Point3D(float x1, float y1, float z1)
Definition: CLHEP/Geometry/Point3D.h:52
HepGeom::operator*
Normal3D< float > operator*(const Transform3D &m, const Normal3D< float > &v)
Definition: Normal3D.cc:25
HepGeom::Point3D< double >::Point3D
Point3D(const BasicVector3D< double > &v)
Definition: CLHEP/Geometry/Point3D.h:153