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