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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/Vector/TwoVector.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Vector/TwoVector.h (Version 10.7)


  1 // -*- C++ -*-                                      1 // -*- C++ -*-
  2 // CLASSDOC OFF                                     2 // CLASSDOC OFF
  3 // -------------------------------------------      3 // ---------------------------------------------------------------------------
  4 // CLASSDOC ON                                      4 // CLASSDOC ON
  5 //                                                  5 //
  6 // This file is a part of the CLHEP - a Class       6 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
  7 //                                                  7 //
  8 // Hep2Vector is a general 2-vector class defi      8 // Hep2Vector is a general 2-vector class defining vectors in two 
  9 // dimension using double components.   It com      9 // dimension using double components.   It comes from the ZOOM
 10 // PlaneVector class (the PhysicsVectors Plane     10 // PlaneVector class (the PhysicsVectors PlaneVector.h will typedef
 11 // PlaneVector to Hep2Vector).                     11 // PlaneVector to Hep2Vector).
 12 //                                                 12 //
 13 // .SS See Also                                    13 // .SS See Also
 14 // ThreeVector.h                                   14 // ThreeVector.h
 15 //                                                 15 //
 16 // .SS Authors                                     16 // .SS Authors
 17 // John Marraffino and Mark Fischler               17 // John Marraffino and Mark Fischler
 18 //                                                 18 //
 19                                                    19 
 20 #ifndef HEP_TWOVECTOR_H                            20 #ifndef HEP_TWOVECTOR_H
 21 #define HEP_TWOVECTOR_H                            21 #define HEP_TWOVECTOR_H
 22                                                    22 
 23 #include <iostream>                                23 #include <iostream>
 24                                                    24 
 25 #include "CLHEP/Vector/ThreeVector.h"              25 #include "CLHEP/Vector/ThreeVector.h" 
 26                                                    26 
 27 namespace CLHEP {                                  27 namespace CLHEP {
 28                                                    28 
 29 // Declarations of classes and global methods      29 // Declarations of classes and global methods
 30 class Hep2Vector;                                  30 class Hep2Vector;
 31 std::ostream & operator << (std::ostream &, co     31 std::ostream & operator << (std::ostream &, const Hep2Vector &);
 32 std::istream & operator >> (std::istream &, He     32 std::istream & operator >> (std::istream &, Hep2Vector &);
 33 inline double operator * (const Hep2Vector & a     33 inline double operator * (const Hep2Vector & a,const Hep2Vector & b);
 34 inline Hep2Vector operator * (const Hep2Vector     34 inline Hep2Vector operator * (const Hep2Vector & p, double a);
 35 inline Hep2Vector operator * (double a, const      35 inline Hep2Vector operator * (double a, const Hep2Vector & p);
 36        Hep2Vector operator / (const Hep2Vector     36        Hep2Vector operator / (const Hep2Vector & p, double a);
 37 inline Hep2Vector operator + (const Hep2Vector     37 inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b);
 38 inline Hep2Vector operator - (const Hep2Vector     38 inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b);
 39                                                    39 
 40 /**                                                40 /**
 41  * @author                                         41  * @author
 42  * @ingroup vector                                 42  * @ingroup vector
 43  */                                                43  */
 44 class Hep2Vector {                                 44 class Hep2Vector {
 45                                                    45 
 46 public:                                            46 public:
 47                                                    47 
 48   enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM     48   enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM_COORDINATES };
 49   // Safe indexing of the coordinates when usi     49   // Safe indexing of the coordinates when using with matrices, arrays, etc.
 50                                                    50 
 51   inline Hep2Vector( double x = 0.0, double y      51   inline Hep2Vector( double x = 0.0, double y = 0.0 );
 52   // The constructor.                              52   // The constructor.
 53                                                    53 
 54   inline Hep2Vector(const Hep2Vector & p);         54   inline Hep2Vector(const Hep2Vector & p);
 55   inline Hep2Vector(Hep2Vector && p) = default     55   inline Hep2Vector(Hep2Vector && p) = default;
 56   // The copy and move constructors.               56   // The copy and move constructors.
 57                                                    57 
 58   explicit Hep2Vector( const Hep3Vector & );       58   explicit Hep2Vector( const Hep3Vector & );
 59   // "demotion" constructor"                       59   // "demotion" constructor"
 60   // WARNING -- THIS IGNORES THE Z COMPONENT O     60   // WARNING -- THIS IGNORES THE Z COMPONENT OF THE Hep3Vector.
 61   //    SO IN GENERAL, Hep2Vector(v)==v WILL N     61   //    SO IN GENERAL, Hep2Vector(v)==v WILL NOT HOLD!
 62                                                    62 
 63   inline ~Hep2Vector();                            63   inline ~Hep2Vector();
 64   // The destructor.                               64   // The destructor.
 65                                                    65 
 66   inline double x() const;                         66   inline double x() const;
 67   inline double y() const;                         67   inline double y() const;
 68   // The components in cartesian coordinate sy     68   // The components in cartesian coordinate system.
 69                                                    69 
 70          double operator () (int i) const;         70          double operator () (int i) const;
 71   inline double operator [] (int i) const;         71   inline double operator [] (int i) const;
 72   // Get components by index.  0-based.            72   // Get components by index.  0-based.
 73                                                    73 
 74          double & operator () (int i);             74          double & operator () (int i);
 75   inline double & operator [] (int i);             75   inline double & operator [] (int i);
 76   // Set components by index.  0-based.            76   // Set components by index.  0-based.
 77                                                    77 
 78   inline void setX(double x);                      78   inline void setX(double x);
 79   inline void setY(double y);                      79   inline void setY(double y);
 80   inline void set (double x, double y);            80   inline void set (double x, double y);
 81   // Set the components in cartesian coordinat     81   // Set the components in cartesian coordinate system.
 82                                                    82 
 83   inline double phi() const;                       83   inline double phi() const;
 84   // The azimuth angle.                            84   // The azimuth angle.
 85                                                    85 
 86   inline double mag2() const;                      86   inline double mag2() const;
 87   // The magnitude squared.                        87   // The magnitude squared.
 88                                                    88 
 89   inline double mag() const;                       89   inline double mag() const;
 90   // The magnitude.                                90   // The magnitude.
 91                                                    91 
 92   inline double r() const;                         92   inline double r() const;
 93   // r in polar coordinates (r, phi):  equal t     93   // r in polar coordinates (r, phi):  equal to mag().
 94                                                    94 
 95   inline void setPhi(double phi);                  95   inline void setPhi(double phi);
 96   // Set phi keeping mag constant.                 96   // Set phi keeping mag constant.
 97                                                    97 
 98   inline void setMag(double r);                    98   inline void setMag(double r);
 99   // Set magnitude keeping phi constant.           99   // Set magnitude keeping phi constant.
100                                                   100 
101   inline void setR(double r);                     101   inline void setR(double r);
102   // Set R keeping phi constant.  Same as setM    102   // Set R keeping phi constant.  Same as setMag.
103                                                   103 
104   inline void setPolar(double r, double phi);     104   inline void setPolar(double r, double phi);
105   // Set by polar coordinates.                    105   // Set by polar coordinates.
106                                                   106 
107   inline Hep2Vector & operator = (const Hep2Ve    107   inline Hep2Vector & operator = (const Hep2Vector & p);
108   inline Hep2Vector & operator = (Hep2Vector &    108   inline Hep2Vector & operator = (Hep2Vector && p) = default;
109   // The copy and move assignment operators.      109   // The copy and move assignment operators.
110                                                   110 
111   inline bool operator == (const Hep2Vector &     111   inline bool operator == (const Hep2Vector & v) const;
112   inline bool operator != (const Hep2Vector &     112   inline bool operator != (const Hep2Vector & v) const;
113   // Comparisons.                                 113   // Comparisons.
114                                                   114 
115   int compare (const Hep2Vector & v) const;       115   int compare (const Hep2Vector & v) const;
116   bool operator > (const Hep2Vector & v) const    116   bool operator > (const Hep2Vector & v) const;
117   bool operator < (const Hep2Vector & v) const    117   bool operator < (const Hep2Vector & v) const;
118   bool operator>= (const Hep2Vector & v) const    118   bool operator>= (const Hep2Vector & v) const;
119   bool operator<= (const Hep2Vector & v) const    119   bool operator<= (const Hep2Vector & v) const;
120   // dictionary ordering according to y, then     120   // dictionary ordering according to y, then x component
121                                                   121 
122   static inline double getTolerance();            122   static inline double getTolerance();
123   static double setTolerance(double tol);         123   static double setTolerance(double tol);
124                                                   124 
125   double howNear (const Hep2Vector &p) const;     125   double howNear (const Hep2Vector &p) const;
126   bool isNear  (const Hep2Vector & p, double e    126   bool isNear  (const Hep2Vector & p, double epsilon=tolerance) const;
127                                                   127 
128   double howParallel (const Hep2Vector &p) con    128   double howParallel (const Hep2Vector &p) const;
129   bool isParallel                                 129   bool isParallel 
130     (const Hep2Vector & p, double epsilon=tole    130     (const Hep2Vector & p, double epsilon=tolerance) const;
131                                                   131 
132   double howOrthogonal (const Hep2Vector &p) c    132   double howOrthogonal (const Hep2Vector &p) const;
133   bool isOrthogonal                               133   bool isOrthogonal
134     (const Hep2Vector & p, double epsilon=tole    134     (const Hep2Vector & p, double epsilon=tolerance) const;
135                                                   135 
136   inline Hep2Vector & operator += (const Hep2V    136   inline Hep2Vector & operator += (const Hep2Vector &p);
137   // Addition.                                    137   // Addition.
138                                                   138 
139   inline Hep2Vector & operator -= (const Hep2V    139   inline Hep2Vector & operator -= (const Hep2Vector &p);
140   // Subtraction.                                 140   // Subtraction.
141                                                   141 
142   inline Hep2Vector operator - () const;          142   inline Hep2Vector operator - () const;
143   // Unary minus.                                 143   // Unary minus.
144                                                   144 
145   inline Hep2Vector & operator *= (double a);     145   inline Hep2Vector & operator *= (double a);
146   // Scaling with real numbers.                   146   // Scaling with real numbers.
147                                                   147 
148   inline Hep2Vector unit() const;                 148   inline Hep2Vector unit() const;
149   // Unit vector parallel to this.                149   // Unit vector parallel to this.
150                                                   150 
151   inline Hep2Vector orthogonal() const;           151   inline Hep2Vector orthogonal() const;
152   // Vector orthogonal to this.                   152   // Vector orthogonal to this.
153                                                   153 
154   inline double dot(const Hep2Vector &p) const    154   inline double dot(const Hep2Vector &p) const;
155   // Scalar product.                              155   // Scalar product.
156                                                   156 
157   inline double angle(const Hep2Vector &) cons    157   inline double angle(const Hep2Vector &) const;
158   // The angle w.r.t. another 2-vector.           158   // The angle w.r.t. another 2-vector.
159                                                   159 
160   void rotate(double);                            160   void rotate(double);
161   // Rotates the Hep2Vector.                      161   // Rotates the Hep2Vector.
162                                                   162 
163   operator Hep3Vector () const;                   163   operator Hep3Vector () const;
164   // Cast a Hep2Vector as a Hep3Vector.           164   // Cast a Hep2Vector as a Hep3Vector.
165                                                   165 
166   // The remaining methods are friends, thus d    166   // The remaining methods are friends, thus defined at global scope:
167   // - - - - - - - - - - - - - - - - - - - - -    167   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
168                                                   168 
169   friend std::ostream & operator<< (std::ostre    169   friend std::ostream & operator<< (std::ostream &, const Hep2Vector &);
170   // Output to a stream.                          170   // Output to a stream.
171                                                   171 
172   inline friend double operator * (const Hep2V    172   inline friend double operator * (const Hep2Vector & a,
173            const Hep2Vector & b);                 173            const Hep2Vector & b);
174   // Scalar product.                              174   // Scalar product.
175                                                   175 
176   inline friend Hep2Vector operator * (const H    176   inline friend Hep2Vector operator * (const Hep2Vector & p, double a);
177   // v*c                                          177   // v*c
178                                                   178 
179   inline friend Hep2Vector operator * (double     179   inline friend Hep2Vector operator * (double a, const Hep2Vector & p);
180   // c*v                                          180   // c*v
181                                                   181 
182          friend Hep2Vector operator / (const H    182          friend Hep2Vector operator / (const Hep2Vector & p, double a);
183   // v/c                                          183   // v/c
184                                                   184 
185   inline friend Hep2Vector operator + (const H    185   inline friend Hep2Vector operator + (const Hep2Vector & a,
186                const Hep2Vector & b);             186                const Hep2Vector & b);
187   // v1+v2                                        187   // v1+v2
188                                                   188 
189   inline friend Hep2Vector operator - (const H    189   inline friend Hep2Vector operator - (const Hep2Vector & a,
190                 const Hep2Vector & b);            190                 const Hep2Vector & b);
191   // v1-v2                                        191   // v1-v2
192                                                   192 
193   static const int ZMpvToleranceTicks = 100;   << 193   enum { ZMpvToleranceTicks = 100 };
194                                                   194 
195 private:                                          195 private:
196                                                   196 
197   double dx;                                      197   double dx;
198   double dy;                                      198   double dy;
199   // The components.                              199   // The components.
200                                                   200 
201   static double tolerance;                        201   static double tolerance;
202   // default tolerance criterion for isNear()     202   // default tolerance criterion for isNear() to return true.
203                                                   203 
204 };  // Hep2Vector                                 204 };  // Hep2Vector
205                                                   205 
206 static const Hep2Vector X_HAT2(1.0, 0.0);         206 static const Hep2Vector X_HAT2(1.0, 0.0);
207 static const Hep2Vector Y_HAT2(0.0, 1.0);         207 static const Hep2Vector Y_HAT2(0.0, 1.0);
208                                                   208 
209 }  // namespace CLHEP                             209 }  // namespace CLHEP
210                                                   210 
211 #include "CLHEP/Vector/TwoVector.icc"             211 #include "CLHEP/Vector/TwoVector.icc"
212                                                   212 
213 #endif /* HEP_TWOVECTOR_H */                      213 #endif /* HEP_TWOVECTOR_H */
214                                                   214