Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RotationZ.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 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  // Copy constructor.
56 
57  inline HepRotationZ & operator = (const HepRotationZ & r);
58  // Assignment from a Rotation, which must be RotationZ
59 
60  HepRotationZ & set ( double delta );
61  // set angle of rotation
62 
63  inline ~HepRotationZ();
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 HepRotationZ & r ) const;
170  // Dictionary-order comparison, in order of delta
171  // Used in operator<, >, <=, >=
172 
173  inline bool operator== ( const HepRotationZ & r ) const;
174  inline bool operator!= ( const HepRotationZ & r ) const;
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 
180  double distance2( const HepRotationZ & 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 HepRotationZ & r ) const;
187  double howNear( const HepRotation & r ) const;
188  bool isNear( const HepRotationZ & r,
190  bool isNear( const HepRotation & r,
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,
202  bool isNear( const HepLorentzRotation & lt,
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 HepRotationZ operator * (const HepRotationZ & rz) const;
230  // Product of two Z rotations: (this) * rz is known to be RotationZ.
231 
232  // Product of two rotations (this) * b - matrix multiplication
233 
234  inline HepRotationZ & operator *= (const HepRotationZ & r);
235  inline HepRotationZ & transform (const HepRotationZ & r);
236  // Matrix multiplication.
237  // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
238  // However, in this special case, they commute: Both just add deltas.
239 
240  inline HepRotationZ inverse() const;
241  // Returns the inverse.
242 
243  friend HepRotationZ inverseOf(const HepRotationZ & r);
244  // Returns the inverse of a RotationZ.
245 
246  inline HepRotationZ & invert();
247  // Inverts the Rotation matrix (be negating delta).
248 
249  // ---------- I/O:
250 
251  std::ostream & print( std::ostream & os ) const;
252  // Output, identifying type of rotation and delta.
253 
254  // ---------- Tolerance
255 
256  static inline double getTolerance();
257  static inline double setTolerance(double tol);
258 
259 protected:
260 
261  double its_d;
262  // The angle of rotation.
263 
264  double its_s;
265  double its_c;
266  // Cache the trig functions, for rapid operations.
267 
268  inline HepRotationZ ( double dd, double ss, double cc );
269  // Unchecked load-the-data-members
270 
271  static inline double proper (double delta);
272  // Put an angle into the range of (-PI, PI]. Useful helper method.
273 
274 }; // HepRotationZ
275 
276 inline
277 std::ostream & operator <<
278  ( std::ostream & os, const HepRotationZ & r ) {return r.print(os);}
279 
280 // ---------- Free-function operations in the group of Rotations
281 
282 } // namespace CLHEP
283 
284 #include "CLHEP/Vector/RotationZ.icc"
285 
286 #endif /* HEP_ROTATIONZ_H */
287 
double delta() const
double phiX() const
Definition: RotationZ.cc:66
double psi() const
Definition: RotationZ.cc:50
bool operator!=(const HepRotationZ &r) const
bool operator<=(const HepRotationZ &r) const
HepLorentzVector row1() const
bool isNear(const HepRotationZ &r, double epsilon=Hep4RotationInterface::tolerance) const
Definition: RotationZ.cc:162
double zy() const
double xx() const
double tt() const
double xt() const
HepLorentzVector row3() const
HepLorentzVector row4() const
Hep3Vector rowZ() const
static double getTolerance()
HepLorentzVector row2() const
HepRotationZ & invert()
const char * p
Definition: xmltok.h:285
static DLL_API double tolerance
HepLorentzVector col4() const
double thetaX() const
Definition: RotationZ.cc:80
double theta() const
Definition: RotationZ.cc:46
void decompose(HepAxisAngle &rotation, Hep3Vector &boost) const
Definition: RotationZ.cc:100
double phi() const
Definition: RotationZ.cc:42
HepRep3x3 rep3x3() const
double yz() const
double zt() const
HepLorentzVector col2() const
double distance2(const HepRotationZ &r) const
Definition: RotationZ.cc:123
Hep3Vector getAxis() const
double getPhi() const
double yt() const
HepBoost inverseOf(const HepBoost &lt)
double zz() const
double phiY() const
Definition: RotationZ.cc:71
Hep3Vector colY() const
double tx() const
HepAxisAngle axisAngle() const
double yy() const
double thetaY() const
Definition: RotationZ.cc:85
Hep3Vector colZ() const
HepRotationZ & operator*=(const HepRotationZ &r)
Hep3Vector rowY() const
double tz() const
HepRotationZ & operator=(const HepRotationZ &r)
HepEulerAngles eulerAngles() const
Definition: RotationZ.cc:54
double getPsi() const
HepRotationZ & transform(const HepRotationZ &r)
bool operator==(const HepRotationZ &r) const
bool operator>=(const HepRotationZ &r) const
Hep3Vector rowX() const
bool isIdentity() const
double getTheta() const
double zx() const
friend HepRotationZ inverseOf(const HepRotationZ &r)
std::ostream & print(std::ostream &os) const
Definition: RotationZ.cc:180
Hep3Vector operator*(const Hep3Vector &p) const
HepRep4x4 rep4x4() const
double thetaZ() const
Definition: RotationZ.cc:90
HepLorentzVector col1() const
HepRotationZ inverse() const
double xy() const
Hep3Vector axis() const
bool operator<(const HepRotationZ &r) const
int compare(const HepRotationZ &r) const
double howNear(const HepRotationZ &r) const
Definition: RotationZ.cc:150
double yx() const
static double proper(double delta)
double phiZ() const
Definition: RotationZ.cc:75
bool operator>(const HepRotationZ &r) const
void getAngleAxis(double &delta, Hep3Vector &axis) const
Hep3Vector colX() const
HepRotationZ & set(double delta)
Definition: RotationZ.cc:35
double xz() const
static double setTolerance(double tol)
double norm2() const
Definition: RotationZ.cc:176
double getDelta() const
HepLorentzVector col3() const
double epsilon(double density, double temperature)
double ty() const
Hep3Vector operator()(const Hep3Vector &p) const
void setDelta(double delta)
Definition: RotationZ.cc:95