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