File indexing completed on 2025-01-18 09:54:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef HEP_TWOVECTOR_H
0021 #define HEP_TWOVECTOR_H
0022
0023 #include <iostream>
0024
0025 #include "CLHEP/Vector/defs.h"
0026 #include "CLHEP/Vector/ThreeVector.h"
0027
0028 namespace CLHEP {
0029
0030
0031 class Hep2Vector;
0032 std::ostream & operator << (std::ostream &, const Hep2Vector &);
0033 std::istream & operator >> (std::istream &, Hep2Vector &);
0034 inline double operator * (const Hep2Vector & a,const Hep2Vector & b);
0035 inline Hep2Vector operator * (const Hep2Vector & p, double a);
0036 inline Hep2Vector operator * (double a, const Hep2Vector & p);
0037 Hep2Vector operator / (const Hep2Vector & p, double a);
0038 inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b);
0039 inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b);
0040
0041
0042
0043
0044
0045 class Hep2Vector {
0046
0047 public:
0048
0049 enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM_COORDINATES };
0050
0051
0052 inline Hep2Vector( double x = 0.0, double y = 0.0 );
0053
0054
0055 inline Hep2Vector(const Hep2Vector & p);
0056 inline Hep2Vector(Hep2Vector && p) = default;
0057
0058
0059 explicit Hep2Vector( const Hep3Vector & );
0060
0061
0062
0063
0064 inline ~Hep2Vector();
0065
0066
0067 inline double x() const;
0068 inline double y() const;
0069
0070
0071 double operator () (int i) const;
0072 inline double operator [] (int i) const;
0073
0074
0075 double & operator () (int i);
0076 inline double & operator [] (int i);
0077
0078
0079 inline void setX(double x);
0080 inline void setY(double y);
0081 inline void set (double x, double y);
0082
0083
0084 inline double phi() const;
0085
0086
0087 inline double mag2() const;
0088
0089
0090 inline double mag() const;
0091
0092
0093 inline double r() const;
0094
0095
0096 inline void setPhi(double phi);
0097
0098
0099 inline void setMag(double r);
0100
0101
0102 inline void setR(double r);
0103
0104
0105 inline void setPolar(double r, double phi);
0106
0107
0108 inline Hep2Vector & operator = (const Hep2Vector & p);
0109 inline Hep2Vector & operator = (Hep2Vector && p) = default;
0110
0111
0112 inline bool operator == (const Hep2Vector & v) const;
0113 inline bool operator != (const Hep2Vector & v) const;
0114
0115
0116 int compare (const Hep2Vector & v) const;
0117 bool operator > (const Hep2Vector & v) const;
0118 bool operator < (const Hep2Vector & v) const;
0119 bool operator>= (const Hep2Vector & v) const;
0120 bool operator<= (const Hep2Vector & v) const;
0121
0122
0123 static inline double getTolerance();
0124 static double setTolerance(double tol);
0125
0126 double howNear (const Hep2Vector &p) const;
0127 bool isNear (const Hep2Vector & p, double epsilon=tolerance) const;
0128
0129 double howParallel (const Hep2Vector &p) const;
0130 bool isParallel
0131 (const Hep2Vector & p, double epsilon=tolerance) const;
0132
0133 double howOrthogonal (const Hep2Vector &p) const;
0134 bool isOrthogonal
0135 (const Hep2Vector & p, double epsilon=tolerance) const;
0136
0137 inline Hep2Vector & operator += (const Hep2Vector &p);
0138
0139
0140 inline Hep2Vector & operator -= (const Hep2Vector &p);
0141
0142
0143 inline Hep2Vector operator - () const;
0144
0145
0146 inline Hep2Vector & operator *= (double a);
0147
0148
0149 inline Hep2Vector unit() const;
0150
0151
0152 inline Hep2Vector orthogonal() const;
0153
0154
0155 inline double dot(const Hep2Vector &p) const;
0156
0157
0158 inline double angle(const Hep2Vector &) const;
0159
0160
0161 void rotate(double);
0162
0163
0164 operator Hep3Vector () const;
0165
0166
0167
0168
0169
0170 friend std::ostream & operator<< (std::ostream &, const Hep2Vector &);
0171
0172
0173 inline friend double operator * (const Hep2Vector & a,
0174 const Hep2Vector & b);
0175
0176
0177 inline friend Hep2Vector operator * (const Hep2Vector & p, double a);
0178
0179
0180 inline friend Hep2Vector operator * (double a, const Hep2Vector & p);
0181
0182
0183 friend Hep2Vector operator / (const Hep2Vector & p, double a);
0184
0185
0186 inline friend Hep2Vector operator + (const Hep2Vector & a,
0187 const Hep2Vector & b);
0188
0189
0190 inline friend Hep2Vector operator - (const Hep2Vector & a,
0191 const Hep2Vector & b);
0192
0193
0194 static const int ZMpvToleranceTicks = 100;
0195
0196 private:
0197
0198 double dx;
0199 double dy;
0200
0201
0202 static double tolerance;
0203
0204
0205 };
0206
0207 static const Hep2Vector X_HAT2(1.0, 0.0);
0208 static const Hep2Vector Y_HAT2(0.0, 1.0);
0209
0210 }
0211
0212 #include "CLHEP/Vector/TwoVector.icc"
0213
0214 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0215
0216 using namespace CLHEP;
0217 #endif
0218
0219
0220 #endif