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