00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef HEP_TWOVECTOR_H
00021 #define HEP_TWOVECTOR_H
00022
00023 #ifdef GNUPRAGMA
00024 #pragma interface
00025 #endif
00026
00027 #include "CLHEP/config/CLHEP.h"
00028 #include "CLHEP/config/iostream.h"
00029
00030 #ifdef HEP_NO_INLINE_IN_DECLARATION
00031 #define inline
00032 #endif
00033
00034 #include "CLHEP/Vector/ThreeVector.h"
00035
00036
00037 class Hep2Vector;
00038 HepStd::ostream & operator << (HepStd::ostream &, const Hep2Vector &);
00039 HepStd::istream & operator >> (HepStd::istream &, Hep2Vector &);
00040 inline double operator * (const Hep2Vector & a,const Hep2Vector & b);
00041 inline Hep2Vector operator * (const Hep2Vector & p, double a);
00042 inline Hep2Vector operator * (double a, const Hep2Vector & p);
00043 Hep2Vector operator / (const Hep2Vector & p, double a);
00044 inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b);
00045 inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b);
00046
00051 class Hep2Vector {
00052
00053 public:
00054
00055 enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM_COORDINATES };
00056
00057
00058 inline Hep2Vector( double x = 0.0, double y = 0.0 );
00059
00060
00061 inline Hep2Vector(const Hep2Vector & p);
00062
00063
00064 explicit Hep2Vector( const Hep3Vector & s);
00065
00066
00067
00068
00069 inline ~Hep2Vector();
00070
00071
00072 inline double x() const;
00073 inline double y() const;
00074
00075
00076 double operator () (int i) const;
00077 inline double operator [] (int i) const;
00078
00079
00080 double & operator () (int i);
00081 inline double & operator [] (int i);
00082
00083
00084 inline void setX(double x);
00085 inline void setY(double y);
00086 inline void set (double x, double y);
00087
00088
00089 inline double phi() const;
00090
00091
00092 inline double mag2() const;
00093
00094
00095 inline double mag() const;
00096
00097
00098 inline double r() const;
00099
00100
00101 inline void setPhi(double phi);
00102
00103
00104 inline void setMag(double r);
00105
00106
00107 inline void setR(double r);
00108
00109
00110 inline void setPolar(double r, double phi);
00111
00112
00113 inline Hep2Vector & operator = (const Hep2Vector & p);
00114
00115
00116 inline bool operator == (const Hep2Vector & v) const;
00117 inline bool operator != (const Hep2Vector & v) const;
00118
00119
00120 int compare (const Hep2Vector & v) const;
00121 bool operator > (const Hep2Vector & v) const;
00122 bool operator < (const Hep2Vector & v) const;
00123 bool operator>= (const Hep2Vector & v) const;
00124 bool operator<= (const Hep2Vector & v) const;
00125
00126
00127 static inline double getTolerance();
00128 static double setTolerance(double tol);
00129
00130 double howNear (const Hep2Vector &p) const;
00131 bool isNear (const Hep2Vector & p, double epsilon=tolerance) const;
00132
00133 double howParallel (const Hep2Vector &p) const;
00134 bool isParallel
00135 (const Hep2Vector & p, double epsilon=tolerance) const;
00136
00137 double howOrthogonal (const Hep2Vector &p) const;
00138 bool isOrthogonal
00139 (const Hep2Vector & p, double epsilon=tolerance) const;
00140
00141 inline Hep2Vector & operator += (const Hep2Vector &p);
00142
00143
00144 inline Hep2Vector & operator -= (const Hep2Vector &p);
00145
00146
00147 inline Hep2Vector operator - () const;
00148
00149
00150 inline Hep2Vector & operator *= (double a);
00151
00152
00153 inline Hep2Vector unit() const;
00154
00155
00156 inline Hep2Vector orthogonal() const;
00157
00158
00159 inline double dot(const Hep2Vector &p) const;
00160
00161
00162 inline double angle(const Hep2Vector &) const;
00163
00164
00165 void rotate(double);
00166
00167
00168 operator Hep3Vector () const;
00169
00170
00171
00172
00173
00174 friend HepStd::ostream & operator<< (HepStd::ostream &, const Hep2Vector &);
00175
00176
00177 inline friend double operator * (const Hep2Vector & a,
00178 const Hep2Vector & b);
00179
00180
00181 inline friend Hep2Vector operator * (const Hep2Vector & p, double a);
00182
00183
00184 inline friend Hep2Vector operator * (double a, const Hep2Vector & p);
00185
00186
00187 friend Hep2Vector operator / (const Hep2Vector & p, double a);
00188
00189
00190 inline friend Hep2Vector operator + (const Hep2Vector & a,
00191 const Hep2Vector & b);
00192
00193
00194 inline friend Hep2Vector operator - (const Hep2Vector & a,
00195 const Hep2Vector & b);
00196
00197
00198 enum { ZMpvToleranceTicks = 100 };
00199
00200 private:
00201
00202 double dx;
00203 double dy;
00204
00205
00206 static double tolerance;
00207
00208
00209 };
00210
00211 static const Hep2Vector X_HAT2(1.0, 0.0);
00212 static const Hep2Vector Y_HAT2(0.0, 1.0);
00213
00214 #include "CLHEP/Vector/TwoVector.icc"
00215
00216
00217 #endif