]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/CLHEP/Vector/ThreeVector.h
This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / PHOS / CLHEP / Vector / ThreeVector.h
1 // -*- C++ -*-
2 // CLASSDOC OFF
3 // $Id$
4 // ---------------------------------------------------------------------------
5 // CLASSDOC ON
6 //
7 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
8 //
9 // Hep3Vector is a general 3-vector class defining vectors in three
10 // dimension using HepDouble components. Rotations of these vectors are
11 // performed by multiplying with an object of the HepRotation class.
12 //
13 // .SS See Also
14 // LorentzVector.h, Rotation.h, LorentzRotation.h
15 //
16 // .SS Authors
17 // Leif Lonnblad and Anders Nilsson.
18 //
19
20 #ifndef HEP_THREEVECTOR_H
21 #define HEP_THREEVECTOR_H
22
23 #ifdef GNUPRAGMA
24 #pragma interface
25 #endif
26
27 #include "CLHEP/config/CLHEP.h"
28
29 #ifdef HEP_NO_INLINE_IN_DECLARATION
30 #define inline
31 #endif
32
33 #include <iostream.h>
34 class HepRotation;
35
36 class Hep3Vector {
37
38 public:
39
40   inline Hep3Vector(HepDouble x = 0.0, HepDouble y = 0.0, HepDouble z = 0.0);
41   // The constructor.
42
43   inline Hep3Vector(const Hep3Vector &);
44   // The copy constructor.
45
46   inline ~Hep3Vector();
47   // The destructor.
48
49   inline HepDouble x() const;
50   inline HepDouble y() const;
51   inline HepDouble z() const;
52   // The components in cartesian coordinate system.
53
54   HepDouble operator () (int) const;
55   // Get components by index (Geant4).
56
57   inline void setX(HepDouble);
58   inline void setY(HepDouble);
59   inline void setZ(HepDouble);
60   // Set the components in cartesian coordinate system.
61
62   inline HepDouble phi() const;
63   // The azimuth angle.
64
65   inline HepDouble theta() const;
66   // The polar angle.
67
68   inline HepDouble cosTheta() const;
69   // Cosine of the polar angle.
70
71   inline HepDouble mag2() const;
72   // The magnitude squared (rho^2 in spherical coordinate system).
73
74   inline HepDouble mag() const;
75   // The magnitude (rho in spherical coordinate system).
76
77   inline void setPhi(HepDouble);
78   // Set phi keeping mag and theta constant (BaBar).
79
80   inline void setTheta(HepDouble);
81   // Set theta keeping mag and phi constant (BaBar).
82
83   inline void setMag(HepDouble);
84   // Set magnitude keeping theta and phi constant (BaBar).
85
86   inline HepDouble perp2() const;
87   // The transverse component squared (R^2 in cylindrical coordinate system).
88
89   inline HepDouble perp() const;
90   // The transverse component (R in cylindrical coordinate system).
91
92   inline HepDouble perp2(const Hep3Vector &) const;
93   // The transverse component w.r.t. given axis squared.
94
95   inline HepDouble perp(const Hep3Vector &) const;
96   // The transverse component w.r.t. given axis.
97
98   inline Hep3Vector & operator = (const Hep3Vector &);
99   // Assignment.
100
101   inline HepBoolean operator == (const Hep3Vector &) const;
102   inline HepBoolean operator != (const Hep3Vector &) const;
103   // Comparisons (Geant4). 
104
105   inline Hep3Vector & operator += (const Hep3Vector &);
106   // Addition.
107
108   inline Hep3Vector & operator -= (const Hep3Vector &);
109   // Subtraction.
110
111   inline Hep3Vector operator - () const;
112   // Unary minus.
113
114   inline Hep3Vector & operator *= (HepDouble);
115   // Scaling with real numbers.
116
117   inline Hep3Vector unit() const;
118   // Unit vector parallel to this.
119
120   inline Hep3Vector orthogonal() const;
121   // Vector orthogonal to this (Geant4).
122
123   inline HepDouble dot(const Hep3Vector &) const;
124   // Scalar product.
125
126   inline Hep3Vector cross(const Hep3Vector &) const;
127   // Cross product.
128
129   inline HepDouble angle(const Hep3Vector &) const;
130   // The angle w.r.t. another 3-vector.
131
132   void rotateX(HepDouble);
133   // Rotates the Hep3Vector around the x-axis.
134
135   void rotateY(HepDouble);
136   // Rotates the Hep3Vector around the y-axis.
137
138   void rotateZ(HepDouble);
139   // Rotates the Hep3Vector around the z-axis.
140
141   void rotateUz(Hep3Vector&);
142   // Rotates reference frame from Uz to newUz (unit vector) (Geant4).
143
144   void rotate(HepDouble, const Hep3Vector &);
145   // Rotates around the axis specified by another Hep3Vector.
146
147   Hep3Vector & operator *= (const HepRotation &);
148   Hep3Vector & transform(const HepRotation &);
149   // Transformation with a Rotation matrix.
150
151 private:
152
153   HepDouble dx, dy, dz;
154   // The components.
155 };
156
157 #ifdef HEP_NO_INLINE_IN_DECLARATION
158 #undef inline
159 #endif
160
161 ostream & operator << (ostream &, const Hep3Vector &);
162 // Output to a stream.
163
164 extern const Hep3Vector HepXHat, HepYHat, HepZHat;
165
166 #ifdef HEP_SHORT_NAMES
167 typedef Hep3Vector Vector3;
168 typedef Hep3Vector DVector3;
169 typedef Hep3Vector FVector3;
170 static const Hep3Vector & xhat = HepXHat;
171 static const Hep3Vector & yhat = HepYHat;
172 static const Hep3Vector & zhat = HepZHat;
173 #endif
174 typedef Hep3Vector HepThreeVectorD;
175 typedef Hep3Vector HepThreeVectorF;
176
177 #ifdef HEP_DEBUG_INLINE
178
179 Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
180 // Addition of 3-vectors.
181
182 Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
183 // Subtraction of 3-vectors.
184
185 HepDouble operator * (const Hep3Vector &, const Hep3Vector &);
186 // Scalar product of 3-vectors.
187
188 Hep3Vector operator * (const Hep3Vector &, HepDouble a);
189 Hep3Vector operator * (HepDouble a, const Hep3Vector &);
190 // Scaling of 3-vectors with a real number
191
192 #else
193 #include "CLHEP/Vector/ThreeVector.icc"
194 #endif
195
196 #endif /* HEP_THREEVECTOR_H */