ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RotationZ.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RotationZ.h
1 // -*- C++ -*-
2 // CLASSDOC OFF
3 // ---------------------------------------------------------------------------
4 // CLASSDOC ON
5 //
6 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
7 //
8 // This is the definition of the HepRotationZ class for performing rotations
9 // around the X axis on objects of the Hep3Vector (and HepLorentzVector) class.
10 //
11 // HepRotationZ is a concrete implementation of Hep3RotationInterface.
12 //
13 // .SS See Also
14 // RotationInterfaces.h
15 // ThreeVector.h, LorentzVector.h, LorentzRotation.h
16 //
17 // .SS Author
18 // Mark Fischler
19 
20 #ifndef HEP_ROTATIONZ_H
21 #define HEP_ROTATIONZ_H
22 
23 #ifdef GNUPRAGMA
24 #pragma interface
25 #endif
26 
28 
29 namespace CLHEP {
30 
31 class HepRotationZ;
32 class HepRotation;
33 class HepBoost;
34 
35 inline HepRotationZ inverseOf(const HepRotationZ & r);
36 // Returns the inverse of a RotationZ.
37 
42 class HepRotationZ {
43 
44 public:
45 
46  // ---------- Constructors and Assignment:
47 
48  inline HepRotationZ();
49  // Default constructor. Gives an identity rotation.
50 
51  HepRotationZ(double delta);
52  // supply angle of rotation
53 
54  inline HepRotationZ(const HepRotationZ & orig);
55  inline HepRotationZ(HepRotationZ && orig) = default;
56  // Copy and move constructors.
57 
58  inline HepRotationZ & operator = (const HepRotationZ & r);
59  inline HepRotationZ & operator = (HepRotationZ && r) = default;
60  // Copy and move assignments from a Rotation, which must be RotationZ
61 
62  HepRotationZ & set ( double delta );
63  // set angle of rotation
64 
65  inline ~HepRotationZ();
66  // Trivial destructor.
67 
68  // ---------- Accessors:
69 
70  inline Hep3Vector colX() const;
71  inline Hep3Vector colY() const;
72  inline Hep3Vector colZ() const;
73  // orthogonal unit-length column vectors
74 
75  inline Hep3Vector rowX() const;
76  inline Hep3Vector rowY() const;
77  inline Hep3Vector rowZ() const;
78  // orthogonal unit-length row vectors
79 
80  inline double xx() const;
81  inline double xy() const;
82  inline double xz() const;
83  inline double yx() const;
84  inline double yy() const;
85  inline double yz() const;
86  inline double zx() const;
87  inline double zy() const;
88  inline double zz() const;
89  // Elements of the rotation matrix (Geant4).
90 
91  inline HepRep3x3 rep3x3() const;
92  // 3x3 representation:
93 
94  // ------------ Euler angles:
95  inline double getPhi () const;
96  inline double getTheta() const;
97  inline double getPsi () const;
98  double phi () const;
99  double theta() const;
100  double psi () const;
101  HepEulerAngles eulerAngles() const;
102 
103  // ------------ axis & angle of rotation:
104  inline double getDelta() const;
105  inline Hep3Vector getAxis () const;
106  inline double delta() const;
107  inline Hep3Vector axis () const;
108  inline HepAxisAngle axisAngle() const;
109  inline void getAngleAxis(double & delta, Hep3Vector & axis) const;
110  // Returns the rotation angle and rotation axis (Geant4).
111 
112  // ------------- Angles of rotated axes
113  double phiX() const;
114  double phiY() const;
115  double phiZ() const;
116  double thetaX() const;
117  double thetaY() const;
118  double thetaZ() const;
119  // Return angles (RADS) made by rotated axes against original axes (Geant4).
120 
121  // ---------- Other accessors treating pure rotation as a 4-rotation
122 
123  inline HepLorentzVector col1() const;
124  inline HepLorentzVector col2() const;
125  inline HepLorentzVector col3() const;
126  // orthosymplectic 4-vector columns - T component will be zero
127 
128  inline HepLorentzVector col4() const;
129  // Will be (0,0,0,1) for this pure Rotation.
130 
131  inline HepLorentzVector row1() const;
132  inline HepLorentzVector row2() const;
133  inline HepLorentzVector row3() const;
134  // orthosymplectic 4-vector rows - T component will be zero
135 
136  inline HepLorentzVector row4() const;
137  // Will be (0,0,0,1) for this pure Rotation.
138 
139  inline double xt() const;
140  inline double yt() const;
141  inline double zt() const;
142  inline double tx() const;
143  inline double ty() const;
144  inline double tz() const;
145  // Will be zero for this pure Rotation
146 
147  inline double tt() const;
148  // Will be one for this pure Rotation
149 
150  inline HepRep4x4 rep4x4() const;
151  // 4x4 representation.
152 
153  // --------- Mutators
154 
155  void setDelta (double delta);
156  // change angle of rotation, leaving rotation axis unchanged.
157 
158  // ---------- Decomposition:
159 
160  void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
161  void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
162  void decompose (HepRotation & rotation, HepBoost & boost) const;
163  void decompose (HepBoost & boost, HepRotation & rotation) const;
164  // These are trivial, as the boost vector is 0.
165 
166  // ---------- Comparisons:
167 
168  inline bool isIdentity() const;
169  // Returns true if the identity matrix (Geant4).
170 
171  inline int compare( const HepRotationZ & r ) const;
172  // Dictionary-order comparison, in order of delta
173  // Used in operator<, >, <=, >=
174 
175  inline bool operator== ( const HepRotationZ & r ) const;
176  inline bool operator!= ( const HepRotationZ & r ) const;
177  inline bool operator< ( const HepRotationZ & r ) const;
178  inline bool operator> ( const HepRotationZ & r ) const;
179  inline bool operator<= ( const HepRotationZ & r ) const;
180  inline bool operator>= ( const HepRotationZ & r ) const;
181 
182  double distance2( const HepRotationZ & r ) const;
183  // 3 - Tr ( this/r )
184 
185  double distance2( const HepRotation & r ) const;
186  // 3 - Tr ( this/r ) -- This works with RotationY or Z also
187 
188  double howNear( const HepRotationZ & r ) const;
189  double howNear( const HepRotation & r ) const;
190  bool isNear( const HepRotationZ & r,
192  bool isNear( const HepRotation & r,
194 
195  double distance2( const HepBoost & lt ) const;
196  // 3 - Tr ( this ) + |b|^2 / (1-|b|^2)
197  double distance2( const HepLorentzRotation & lt ) const;
198  // 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
199 
200  double howNear( const HepBoost & lt ) const;
201  double howNear( const HepLorentzRotation & lt ) const;
202  bool isNear( const HepBoost & lt,
204  bool isNear( const HepLorentzRotation & lt,
206 
207  // ---------- Properties:
208 
209  double norm2() const;
210  // distance2 (IDENTITY), which is 3 - Tr ( *this )
211 
212  inline void rectify();
213  // non-const but logically moot correction for accumulated roundoff errors
214 
215  // ---------- Application:
216 
217  inline Hep3Vector operator() (const Hep3Vector & p) const;
218  // Rotate a Hep3Vector.
219 
220  inline Hep3Vector operator * (const Hep3Vector & p) const;
221  // Multiplication with a Hep3Vector.
222 
223  inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
224  // Rotate (the space part of) a HepLorentzVector.
225 
226  inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
227  // Multiplication with a HepLorentzVector.
228 
229  // ---------- Operations in the group of Rotations
230 
231  inline HepRotationZ operator * (const HepRotationZ & rz) const;
232  // Product of two Z rotations: (this) * rz is known to be RotationZ.
233 
234  // Product of two rotations (this) * b - matrix multiplication
235 
236  inline HepRotationZ & operator *= (const HepRotationZ & r);
237  inline HepRotationZ & transform (const HepRotationZ & r);
238  // Matrix multiplication.
239  // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
240  // However, in this special case, they commute: Both just add deltas.
241 
242  inline HepRotationZ inverse() const;
243  // Returns the inverse.
244 
245  friend HepRotationZ inverseOf(const HepRotationZ & r);
246  // Returns the inverse of a RotationZ.
247 
248  inline HepRotationZ & invert();
249  // Inverts the Rotation matrix (be negating delta).
250 
251  // ---------- I/O:
252 
253  std::ostream & print( std::ostream & os ) const;
254  // Output, identifying type of rotation and delta.
255 
256  // ---------- Tolerance
257 
258  static inline double getTolerance();
259  static inline double setTolerance(double tol);
260 
261 protected:
262 
263  double its_d;
264  // The angle of rotation.
265 
266  double its_s;
267  double its_c;
268  // Cache the trig functions, for rapid operations.
269 
270  inline HepRotationZ ( double dd, double ss, double cc );
271  // Unchecked load-the-data-members
272 
273  static inline double proper (double delta);
274  // Put an angle into the range of (-PI, PI]. Useful helper method.
275 
276 }; // HepRotationZ
277 
278 inline
279 std::ostream & operator <<
280  ( std::ostream & os, const HepRotationZ & r ) {return r.print(os);}
281 
282 // ---------- Free-function operations in the group of Rotations
283 
284 } // namespace CLHEP
285 
286 #include "CLHEP/Vector/RotationZ.icc"
287 
288 #endif /* HEP_ROTATIONZ_H */
289