00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef HEP_THREEVECTOR_H
00022 #define HEP_THREEVECTOR_H
00023
00024 #ifdef GNUPRAGMA
00025 #pragma interface
00026 #endif
00027
00028 #include "CLHEP/config/CLHEP.h"
00029 #include "CLHEP/config/iostream.h"
00030
00031 #ifdef HEP_NO_INLINE_IN_DECLARATION
00032 #define inline
00033 #endif
00034
00035 class HepRotation;
00036 class HepEulerAngles;
00037 class HepAxisAngle;
00038
00043 class Hep3Vector {
00044
00045 public:
00046
00047
00048
00049 enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
00050
00051
00052
00053 inline Hep3Vector(double x = 0.0, double y = 0.0, double z = 0.0);
00054
00055
00056 inline Hep3Vector(const Hep3Vector &);
00057
00058
00059 inline ~Hep3Vector();
00060
00061
00062 double operator () (int) const;
00063
00064
00065 inline double operator [] (int) const;
00066
00067
00068 double & operator () (int);
00069
00070
00071 inline double & operator [] (int);
00072
00073
00074 inline double x() const;
00075 inline double y() const;
00076 inline double z() const;
00077
00078
00079 inline void setX(double);
00080 inline void setY(double);
00081 inline void setZ(double);
00082
00083
00084 inline void set( double x, double y, double z);
00085
00086
00087 inline double phi() const;
00088
00089
00090 inline double theta() const;
00091
00092
00093 inline double cosTheta() const;
00094
00095
00096 inline double cos2Theta() const;
00097
00098
00099 inline double mag2() const;
00100
00101
00102 inline double mag() const;
00103
00104
00105 inline void setPhi(double);
00106
00107
00108 inline void setTheta(double);
00109
00110
00111 void setMag(double);
00112
00113
00114 inline double perp2() const;
00115
00116
00117 inline double perp() const;
00118
00119
00120 inline void setPerp(double);
00121
00122
00123 void setCylTheta(double);
00124
00125
00126 inline double perp2(const Hep3Vector &) const;
00127
00128
00129 inline double perp(const Hep3Vector &) const;
00130
00131
00132 inline Hep3Vector & operator = (const Hep3Vector &);
00133
00134
00135 inline bool operator == (const Hep3Vector &) const;
00136 inline bool operator != (const Hep3Vector &) const;
00137
00138
00139 bool isNear (const Hep3Vector &, double epsilon=tolerance) const;
00140
00141
00142
00143 double howNear(const Hep3Vector & v ) const;
00144
00145
00146
00147 double deltaR(const Hep3Vector & v) const;
00148
00149
00150 inline Hep3Vector & operator += (const Hep3Vector &);
00151
00152
00153 inline Hep3Vector & operator -= (const Hep3Vector &);
00154
00155
00156 inline Hep3Vector operator - () const;
00157
00158
00159 inline Hep3Vector & operator *= (double);
00160
00161
00162 Hep3Vector & operator /= (double);
00163
00164
00165 inline Hep3Vector unit() const;
00166
00167
00168 inline Hep3Vector orthogonal() const;
00169
00170
00171 inline double dot(const Hep3Vector &) const;
00172
00173
00174 inline Hep3Vector cross(const Hep3Vector &) const;
00175
00176
00177 double angle(const Hep3Vector &) const;
00178
00179
00180 double pseudoRapidity() const;
00181
00182
00183 void setEta ( double p );
00184
00185
00186 void setCylEta ( double p );
00187
00188
00189 Hep3Vector & rotateX(double);
00190
00191
00192 Hep3Vector & rotateY(double);
00193
00194
00195 Hep3Vector & rotateZ(double);
00196
00197
00198 Hep3Vector & rotateUz(const Hep3Vector&);
00199
00200
00201 Hep3Vector & rotate(double, const Hep3Vector &);
00202
00203
00204
00205 Hep3Vector & operator *= (const HepRotation &);
00206 Hep3Vector & transform(const HepRotation &);
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 inline void setRThetaPhi (double r, double theta, double phi);
00227
00228
00229 inline void setREtaPhi ( double r, double eta, double phi );
00230
00231
00232 inline void setRhoPhiZ (double rho, double phi, double z);
00233
00234
00235 void setRhoPhiTheta ( double rho, double phi, double theta);
00236
00237
00238 void setRhoPhiEta ( double rho, double phi, double eta);
00239
00240
00241
00242
00243 inline double getX() const;
00244 inline double getY() const;
00245 inline double getZ() const;
00246
00247
00248 inline double getR () const;
00249 inline double getTheta() const;
00250 inline double getPhi () const;
00251
00252
00253 inline double r () const;
00254
00255
00256 inline double rho () const;
00257 inline double getRho () const;
00258
00259
00260 double eta () const;
00261 double getEta () const;
00262
00263
00264 inline void setR ( double s );
00265
00266
00267 inline void setRho ( double s );
00268
00269
00270
00271
00272 int compare (const Hep3Vector & v) const;
00273 bool operator > (const Hep3Vector & v) const;
00274 bool operator < (const Hep3Vector & v) const;
00275 bool operator>= (const Hep3Vector & v) const;
00276 bool operator<= (const Hep3Vector & v) const;
00277
00278
00279 inline double diff2 (const Hep3Vector & v) const;
00280
00281
00282 static double setTolerance (double tol);
00283 static inline double getTolerance ();
00284
00285
00286 bool isParallel (const Hep3Vector & v, double epsilon=tolerance) const;
00287
00288
00289 bool isOrthogonal (const Hep3Vector & v, double epsilon=tolerance) const;
00290
00291
00292 double howParallel (const Hep3Vector & v) const;
00293
00294
00295 double howOrthogonal (const Hep3Vector & v) const;
00296
00297
00298 enum { ToleranceTicks = 100 };
00299
00300
00301
00302 double beta () const;
00303
00304
00305
00306 double gamma() const;
00307
00308
00309 double coLinearRapidity() const;
00310
00311
00312
00313
00314
00315
00316
00317 inline double angle() const;
00318
00319
00320 inline double theta(const Hep3Vector & v2) const;
00321
00322
00323 double cosTheta (const Hep3Vector & v2) const;
00324 double cos2Theta(const Hep3Vector & v2) const;
00325
00326
00327 inline Hep3Vector project () const;
00328 Hep3Vector project (const Hep3Vector & v2) const;
00329
00330
00331 inline Hep3Vector perpPart() const;
00332 inline Hep3Vector perpPart (const Hep3Vector & v2) const;
00333
00334
00335 double rapidity () const;
00336
00337
00338 double rapidity (const Hep3Vector & v2) const;
00339
00340
00341
00342 double eta(const Hep3Vector & v2) const;
00343
00344
00345
00346
00347
00348
00349 double polarAngle (const Hep3Vector & v2) const;
00350
00351
00352 double deltaPhi (const Hep3Vector & v2) const;
00353
00354
00355 double azimAngle (const Hep3Vector & v2) const;
00356
00357
00358 double polarAngle (const Hep3Vector & v2,
00359 const Hep3Vector & ref) const;
00360
00361
00362
00363 double azimAngle (const Hep3Vector & v2,
00364 const Hep3Vector & ref) const;
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 Hep3Vector & rotate (const Hep3Vector & axis, double delta);
00375
00376
00377 Hep3Vector & rotate (const HepAxisAngle & ax);
00378
00379
00380 Hep3Vector & rotate (const HepEulerAngles & e);
00381 Hep3Vector & rotate (double phi,
00382 double theta,
00383 double psi);
00384
00385
00386
00387 protected:
00388 void setSpherical (double r, double theta, double phi);
00389 void setCylindrical (double r, double phi, double z);
00390 double negativeInfinity() const;
00391
00392 protected:
00393
00394 double dx;
00395 double dy;
00396 double dz;
00397
00398
00399 static double tolerance;
00400
00401 };
00402
00403
00404
00405 Hep3Vector rotationXOf (const Hep3Vector & vec, double delta);
00406 Hep3Vector rotationYOf (const Hep3Vector & vec, double delta);
00407 Hep3Vector rotationZOf (const Hep3Vector & vec, double delta);
00408
00409 Hep3Vector rotationOf (const Hep3Vector & vec,
00410 const Hep3Vector & axis, double delta);
00411 Hep3Vector rotationOf (const Hep3Vector & vec, const HepAxisAngle & ax);
00412
00413 Hep3Vector rotationOf (const Hep3Vector & vec,
00414 double phi, double theta, double psi);
00415 Hep3Vector rotationOf (const Hep3Vector & vec, const HepEulerAngles & e);
00416
00417
00418 HepStd::ostream & operator << (HepStd::ostream &, const Hep3Vector &);
00419
00420
00421 HepStd::istream & operator >> (HepStd::istream &, Hep3Vector &);
00422
00423
00424 extern const Hep3Vector HepXHat, HepYHat, HepZHat;
00425
00426 #ifdef HEP_SHORT_NAMES
00427 typedef Hep3Vector Vector3;
00428 typedef Hep3Vector DVector3;
00429 typedef Hep3Vector FVector3;
00430 static const Hep3Vector & xhat = HepXHat;
00431 static const Hep3Vector & yhat = HepYHat;
00432 static const Hep3Vector & zhat = HepZHat;
00433 #endif
00434 typedef Hep3Vector HepThreeVectorD;
00435 typedef Hep3Vector HepThreeVectorF;
00436
00437 Hep3Vector operator / (const Hep3Vector &, double a);
00438
00439
00440 #ifdef HEP_NO_INLINE_IN_DECLARATION
00441 #undef inline
00442 #endif
00443
00444 #ifdef HEP_DEBUG_INLINE
00445
00446
00447
00448
00449
00450
00451
00452
00453 Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
00454
00455
00456 Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
00457
00458
00459 double operator * (const Hep3Vector &, const Hep3Vector &);
00460
00461
00462 Hep3Vector operator * (const Hep3Vector &, double a);
00463 Hep3Vector operator * (double a, const Hep3Vector &);
00464
00465
00466 #else
00467 #include "CLHEP/Vector/ThreeVector.icc"
00468 #endif
00469
00470 #endif