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10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/include/CLHEP/Geometry/Point3D.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Geometry/Point3D.h (Version 10.0.p4)


  1 // -*- C++ -*-                                      1 // -*- C++ -*-
                                                   >>   2 // $Id:$
  2 // -------------------------------------------      3 // ---------------------------------------------------------------------------
  3 //                                                  4 //
  4 // This file is a part of the CLHEP - a Class       5 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
  5 //                                                  6 //
  6 // History:                                         7 // History:
  7 // 09.09.96 E.Chernyaev - initial version           8 // 09.09.96 E.Chernyaev - initial version
  8 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduct      9 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
  9 //                        the functionality fr     10 //                        the functionality from CLHEP::Hep3Vector
 10 // 01.04.03 E.Chernyaev - CLHEP-1.9: template      11 // 01.04.03 E.Chernyaev - CLHEP-1.9: template version
 11 //                                                 12 //
 12                                                    13 
 13 #ifndef HEP_POINT3D_H                              14 #ifndef HEP_POINT3D_H
 14 #define HEP_POINT3D_H                              15 #define HEP_POINT3D_H
 15                                                    16 
 16 #include <iosfwd>                                  17 #include <iosfwd>
 17 #include "CLHEP/Vector/ThreeVector.h"              18 #include "CLHEP/Vector/ThreeVector.h"
 18 #include "CLHEP/Geometry/BasicVector3D.h"          19 #include "CLHEP/Geometry/BasicVector3D.h"
 19                                                    20 
 20 namespace HepGeom {                                21 namespace HepGeom {
 21                                                    22 
 22   class Transform3D;                               23   class Transform3D;
 23                                                    24 
 24   /**                                              25   /**
 25    * Geometrical 3D Point.                         26    * Geometrical 3D Point.
 26    * This is just a declaration of the class n     27    * This is just a declaration of the class needed to define
 27    * specializations Point3D<float> and Point3     28    * specializations Point3D<float> and Point3D<double>.
 28    *                                               29    *
 29    * @ingroup geometry                             30    * @ingroup geometry
 30    * @author Evgeni Chernyaev <Evgueni.Tcherni     31    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
 31    */                                              32    */
 32   template<class T>                                33   template<class T>
 33   class Point3D : public BasicVector3D<T> {};      34   class Point3D : public BasicVector3D<T> {};
 34                                                    35 
 35   /**                                              36   /**
 36    * Geometrical 3D Point with components of f     37    * Geometrical 3D Point with components of float type.
 37    *                                               38    *
 38    * @author Evgeni Chernyaev <Evgueni.Tcherni     39    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
 39    * @ingroup geometry                             40    * @ingroup geometry
 40    */                                              41    */
 41   template<>                                       42   template<>
 42   class Point3D<float> : public BasicVector3D<     43   class Point3D<float> : public BasicVector3D<float> {
 43   public:                                          44   public:
 44     /**                                            45     /**
 45      * Default constructor. */                     46      * Default constructor. */
 46     Point3D() = default;                       <<  47     Point3D() {}
 47                                                    48 
 48     /**                                            49     /**
 49      * Constructor from three numbers. */          50      * Constructor from three numbers. */
 50     Point3D(float x1, float y1, float z1) : Ba     51     Point3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
 51                                                    52 
 52     /**                                            53     /**
 53      * Constructor from array of floats. */        54      * Constructor from array of floats. */
 54     explicit Point3D(const float * a)              55     explicit Point3D(const float * a)
 55       : BasicVector3D<float>(a[0],a[1],a[2]) {     56       : BasicVector3D<float>(a[0],a[1],a[2]) {}
 56                                                    57 
 57     /**                                            58     /**
 58      * Copy constructor. */                        59      * Copy constructor. */
 59     Point3D(const Point3D<float> &) = default; <<  60     Point3D(const Point3D<float> & v) : BasicVector3D<float>(v) {}
 60                                                << 
 61     /**                                        << 
 62      * Move constructor. */                    << 
 63     Point3D(Point3D<float> &&) = default;      << 
 64                                                    61 
 65     /**                                            62     /**
 66      * Constructor from BasicVector3D<float>.      63      * Constructor from BasicVector3D<float>. */
 67     Point3D(const BasicVector3D<float> & v) :      64     Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
 68                                                    65 
 69     /**                                            66     /**
 70      * Destructor. */                              67      * Destructor. */
 71     ~Point3D() = default;                      <<  68     ~Point3D() {}
 72                                                    69 
 73     /**                                            70     /**
 74      * Assignment. */                              71      * Assignment. */
 75     Point3D<float> & operator=(const Point3D<f <<  72     Point3D<float> & operator=(const Point3D<float> & v) {
                                                   >>  73       set(v.x(),v.y(),v.z()); return *this;
                                                   >>  74     }
 76                                                    75 
 77     /**                                            76     /**
 78      * Assignment from BasicVector3D<float>. *     77      * Assignment from BasicVector3D<float>. */
 79     Point3D<float> & operator=(const BasicVect     78     Point3D<float> & operator=(const BasicVector3D<float> & v) {
 80       this->BasicVector3D<float>::operator=(v) <<  79       set(v.x(),v.y(),v.z()); return *this;
 81       return *this;                            << 
 82     }                                              80     }
 83                                                    81 
 84     /**                                            82     /**
 85      * Move assignment. */                     << 
 86     Point3D<float> & operator=(Point3D<float>  << 
 87                                                << 
 88     /**                                        << 
 89      * Returns distance to the origin squared.     83      * Returns distance to the origin squared. */
 90     float distance2() const { return mag2(); }     84     float distance2() const { return mag2(); }
 91                                                    85 
 92     /**                                            86     /**
 93      * Returns distance to the point squared.      87      * Returns distance to the point squared. */
 94     float distance2(const Point3D<float> & p)      88     float distance2(const Point3D<float> & p) const {
 95       float dx = p.x()-x(), dy = p.y()-y(), dz     89       float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
 96       return dx*dx + dy*dy + dz*dz;                90       return dx*dx + dy*dy + dz*dz;
 97     }                                              91     }
 98                                                    92 
 99     /**                                            93     /**
100      * Returns distance to the origin. */          94      * Returns distance to the origin. */
101     float distance() const { return std::sqrt(     95     float distance() const { return std::sqrt(distance2()); }
102                                                    96 
103     /**                                            97     /**
104      * Returns distance to the point. */           98      * Returns distance to the point. */
105     float distance(const Point3D<float> & p) c     99     float distance(const Point3D<float> & p) const {
106       return std::sqrt(distance2(p));             100       return std::sqrt(distance2(p));
107     }                                             101     }
108                                                   102 
109     /**                                           103     /**
110      * Transformation by Transform3D. */          104      * Transformation by Transform3D. */
111     Point3D<float> & transform(const Transform    105     Point3D<float> & transform(const Transform3D & m);
112   };                                              106   };
113                                                   107 
114   /**                                             108   /**
115    * Transformation of Point3D<float> by Trans    109    * Transformation of Point3D<float> by Transform3D.
116    * @relates Point3D                             110    * @relates Point3D
117    */                                             111    */
118   Point3D<float>                                  112   Point3D<float>
119   operator*(const Transform3D & m, const Point    113   operator*(const Transform3D & m, const Point3D<float> & p);
120                                                   114 
121   /**                                             115   /**
122    * Geometrical 3D Point with components of d    116    * Geometrical 3D Point with components of double type.
123    *                                              117    *
124    * @author Evgeni Chernyaev <Evgueni.Tcherni    118    * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
125    * @ingroup geometry                            119    * @ingroup geometry
126    */                                             120    */
127   template<>                                      121   template<>
128   class Point3D<double> : public BasicVector3D    122   class Point3D<double> : public BasicVector3D<double> {
129   public:                                         123   public:
130     /**                                           124     /**
131      * Default constructor. */                    125      * Default constructor. */
132     Point3D() = default;                       << 126     Point3D() {}
133                                                   127 
134     /**                                           128     /**
135      * Constructor from three numbers. */         129      * Constructor from three numbers. */
136     Point3D(double x1, double y1, double z1) :    130     Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
137                                                   131 
138     /**                                           132     /**
139      * Constructor from array of floats. */       133      * Constructor from array of floats. */
140     explicit Point3D(const float * a)             134     explicit Point3D(const float * a)
141       : BasicVector3D<double>(a[0],a[1],a[2])     135       : BasicVector3D<double>(a[0],a[1],a[2]) {}
142                                                   136 
143     /**                                           137     /**
144      * Constructor from array of doubles. */      138      * Constructor from array of doubles. */
145     explicit Point3D(const double * a)            139     explicit Point3D(const double * a)
146       : BasicVector3D<double>(a[0],a[1],a[2])     140       : BasicVector3D<double>(a[0],a[1],a[2]) {}
147                                                   141 
148     /**                                           142     /**
149      * Copy constructor. */                       143      * Copy constructor. */
150     Point3D(const Point3D<double> &) = default << 144     Point3D(const Point3D<double> & v) : BasicVector3D<double>(v) {}
151                                                << 
152     /**                                        << 
153      * Move constructor. */                    << 
154     Point3D(Point3D<double> &&) = default;     << 
155                                                   145 
156     /**                                           146     /**
157      * Constructor from BasicVector3D<float>.     147      * Constructor from BasicVector3D<float>. */
158     Point3D(const BasicVector3D<float> & v) :     148     Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
159                                                   149 
160     /**                                           150     /**
161      * Constructor from BasicVector3D<double>.    151      * Constructor from BasicVector3D<double>. */
162     Point3D(const BasicVector3D<double> & v) :    152     Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
163                                                   153 
164     /**                                           154     /**
165      * Destructor. */                             155      * Destructor. */
166     ~Point3D() = default;                      << 156     ~Point3D() {}
167                                                   157 
168     /**                                           158     /**
169      * Constructor from CLHEP::Hep3Vector.        159      * Constructor from CLHEP::Hep3Vector.
170      * This constructor is needed only for bac    160      * This constructor is needed only for backward compatibility and
171      * in principle should be absent.             161      * in principle should be absent.
172      */                                           162      */
173     Point3D(const CLHEP::Hep3Vector & v)          163     Point3D(const CLHEP::Hep3Vector & v)
174       : BasicVector3D<double>(v.x(),v.y(),v.z(    164       : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
175                                                   165 
176     /**                                           166     /**
177      * Conversion (cast) to CLHEP::Hep3Vector.    167      * Conversion (cast) to CLHEP::Hep3Vector.
178      * This operator is needed only for backwa    168      * This operator is needed only for backward compatibility and
179      * in principle should not exit.              169      * in principle should not exit.
180      */                                        << 170      */ 
181     operator CLHEP::Hep3Vector () const { retu    171     operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
182                                                   172 
183     /**                                           173     /**
184      * Assignment. */                             174      * Assignment. */
185     Point3D<double> & operator=(const Point3D< << 175     Point3D<double> & operator=(const Point3D<double> & v) {
                                                   >> 176       set(v.x(),v.y(),v.z()); return *this;
                                                   >> 177     }
186                                                   178 
187     /**                                           179     /**
188      * Assignment from BasicVector3D<float>. *    180      * Assignment from BasicVector3D<float>. */
189     Point3D<double> & operator=(const BasicVec    181     Point3D<double> & operator=(const BasicVector3D<float> & v) {
190       this->BasicVector3D<double>::operator=(v << 182       set(v.x(),v.y(),v.z()); return *this;
191       return *this;                            << 
192     }                                             183     }
193                                                   184 
194     /**                                           185     /**
195      * Assignment from BasicVector3D<double>.     186      * Assignment from BasicVector3D<double>. */
196     Point3D<double> & operator=(const BasicVec    187     Point3D<double> & operator=(const BasicVector3D<double> & v) {
197       this->BasicVector3D<double>::operator=(v << 188       set(v.x(),v.y(),v.z()); return *this;
198       return *this;                            << 
199     }                                             189     }
200                                                << 
201     /**                                        << 
202      * Move assignment. */                     << 
203     Point3D<double> & operator=(Point3D<double << 
204                                                   190 
205     /**                                           191     /**
206      * Returns distance to the origin squared.    192      * Returns distance to the origin squared. */
207     double distance2() const { return mag2();     193     double distance2() const { return mag2(); }
208                                                   194 
209     /**                                           195     /**
210      * Returns distance to the point squared.     196      * Returns distance to the point squared. */
211     double distance2(const Point3D<double> & p    197     double distance2(const Point3D<double> & p) const {
212       double dx = p.x()-x(), dy = p.y()-y(), d    198       double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
213       return dx*dx + dy*dy + dz*dz;               199       return dx*dx + dy*dy + dz*dz;
214     }                                             200     }
215                                                   201 
216     /**                                           202     /**
217      * Returns distance to the origin. */         203      * Returns distance to the origin. */
218     double distance() const { return std::sqrt    204     double distance() const { return std::sqrt(distance2()); }
219                                                   205 
220     /**                                           206     /**
221      * Returns distance to the point. */          207      * Returns distance to the point. */
222     double distance(const Point3D<double> & p)    208     double distance(const Point3D<double> & p) const {
223       return std::sqrt(distance2(p));             209       return std::sqrt(distance2(p));
224     }                                             210     }
225                                                   211 
226     /**                                           212     /**
227      * Transformation by Transform3D. */          213      * Transformation by Transform3D. */
228     Point3D<double> & transform(const Transfor    214     Point3D<double> & transform(const Transform3D & m);
229   };                                              215   };
230                                                   216 
231   /**                                             217   /**
232    * Transformation of Point3D<double> by Tran    218    * Transformation of Point3D<double> by Transform3D.
233    * @relates Point3D                             219    * @relates Point3D
234    */                                             220    */
235   Point3D<double>                                 221   Point3D<double>
236   operator*(const Transform3D & m, const Point    222   operator*(const Transform3D & m, const Point3D<double> & p);
237                                                   223 
238 } /* namespace HepGeom */                         224 } /* namespace HepGeom */
239                                                   225 
240 #endif /* HEP_POINT3D_H */                        226 #endif /* HEP_POINT3D_H */
241                                                   227