4 // ---------------------------------------------------------------------------
7 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
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.
14 // LorentzVector.h, Rotation.h, LorentzRotation.h
17 // Leif Lonnblad and Anders Nilsson.
20 #ifndef HEP_THREEVECTOR_H
21 #define HEP_THREEVECTOR_H
27 #include "CLHEP/config/CLHEP.h"
29 #ifdef HEP_NO_INLINE_IN_DECLARATION
40 inline Hep3Vector(HepDouble x = 0.0, HepDouble y = 0.0, HepDouble z = 0.0);
43 inline Hep3Vector(const Hep3Vector &);
44 // The copy constructor.
49 inline HepDouble x() const;
50 inline HepDouble y() const;
51 inline HepDouble z() const;
52 // The components in cartesian coordinate system.
54 HepDouble operator () (int) const;
55 // Get components by index (Geant4).
57 inline void setX(HepDouble);
58 inline void setY(HepDouble);
59 inline void setZ(HepDouble);
60 // Set the components in cartesian coordinate system.
62 inline HepDouble phi() const;
65 inline HepDouble theta() const;
68 inline HepDouble cosTheta() const;
69 // Cosine of the polar angle.
71 inline HepDouble mag2() const;
72 // The magnitude squared (rho^2 in spherical coordinate system).
74 inline HepDouble mag() const;
75 // The magnitude (rho in spherical coordinate system).
77 inline void setPhi(HepDouble);
78 // Set phi keeping mag and theta constant (BaBar).
80 inline void setTheta(HepDouble);
81 // Set theta keeping mag and phi constant (BaBar).
83 inline void setMag(HepDouble);
84 // Set magnitude keeping theta and phi constant (BaBar).
86 inline HepDouble perp2() const;
87 // The transverse component squared (R^2 in cylindrical coordinate system).
89 inline HepDouble perp() const;
90 // The transverse component (R in cylindrical coordinate system).
92 inline HepDouble perp2(const Hep3Vector &) const;
93 // The transverse component w.r.t. given axis squared.
95 inline HepDouble perp(const Hep3Vector &) const;
96 // The transverse component w.r.t. given axis.
98 inline Hep3Vector & operator = (const Hep3Vector &);
101 inline HepBoolean operator == (const Hep3Vector &) const;
102 inline HepBoolean operator != (const Hep3Vector &) const;
103 // Comparisons (Geant4).
105 inline Hep3Vector & operator += (const Hep3Vector &);
108 inline Hep3Vector & operator -= (const Hep3Vector &);
111 inline Hep3Vector operator - () const;
114 inline Hep3Vector & operator *= (HepDouble);
115 // Scaling with real numbers.
117 inline Hep3Vector unit() const;
118 // Unit vector parallel to this.
120 inline Hep3Vector orthogonal() const;
121 // Vector orthogonal to this (Geant4).
123 inline HepDouble dot(const Hep3Vector &) const;
126 inline Hep3Vector cross(const Hep3Vector &) const;
129 inline HepDouble angle(const Hep3Vector &) const;
130 // The angle w.r.t. another 3-vector.
132 void rotateX(HepDouble);
133 // Rotates the Hep3Vector around the x-axis.
135 void rotateY(HepDouble);
136 // Rotates the Hep3Vector around the y-axis.
138 void rotateZ(HepDouble);
139 // Rotates the Hep3Vector around the z-axis.
141 void rotateUz(Hep3Vector&);
142 // Rotates reference frame from Uz to newUz (unit vector) (Geant4).
144 void rotate(HepDouble, const Hep3Vector &);
145 // Rotates around the axis specified by another Hep3Vector.
147 Hep3Vector & operator *= (const HepRotation &);
148 Hep3Vector & transform(const HepRotation &);
149 // Transformation with a Rotation matrix.
153 HepDouble dx, dy, dz;
157 #ifdef HEP_NO_INLINE_IN_DECLARATION
161 ostream & operator << (ostream &, const Hep3Vector &);
162 // Output to a stream.
164 extern const Hep3Vector HepXHat, HepYHat, HepZHat;
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;
174 typedef Hep3Vector HepThreeVectorD;
175 typedef Hep3Vector HepThreeVectorF;
177 #ifdef HEP_DEBUG_INLINE
179 Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
180 // Addition of 3-vectors.
182 Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
183 // Subtraction of 3-vectors.
185 HepDouble operator * (const Hep3Vector &, const Hep3Vector &);
186 // Scalar product of 3-vectors.
188 Hep3Vector operator * (const Hep3Vector &, HepDouble a);
189 Hep3Vector operator * (HepDouble a, const Hep3Vector &);
190 // Scaling of 3-vectors with a real number
193 #include "CLHEP/Vector/ThreeVector.icc"
196 #endif /* HEP_THREEVECTOR_H */