CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Geometry/CLHEP/Vector/Rotation.h
Go to the documentation of this file.
1// -*- C++ -*-
2// CLASSDOC OFF
3// $Id: Rotation.h,v 1.3 2003/10/23 21:29:52 garren Exp $
4// ---------------------------------------------------------------------------
5// CLASSDOC ON
6//
7// This file is a part of the CLHEP - a Class Library for High Energy Physics.
8//
9// This is the definition of the HepRotation class for performing rotations
10// on objects of the Hep3Vector (and HepLorentzVector) class.
11//
12// HepRotation is a concrete implementation of Hep3RotationInterface.
13//
14// .SS See Also
15// RotationInterfaces.h
16// ThreeVector.h, LorentzVector.h, LorentzRotation.h
17//
18// .SS Author
19// Leif Lonnblad, Mark Fischler
20
21#ifndef HEP_ROTATION_H
22#define HEP_ROTATION_H
23
24#ifdef GNUPRAGMA
25#pragma interface
26#endif
27
28#include "CLHEP/Vector/defs.h"
29#include "CLHEP/Vector/RotationInterfaces.h"
30#include "CLHEP/Vector/RotationX.h"
31#include "CLHEP/Vector/RotationY.h"
32#include "CLHEP/Vector/RotationZ.h"
33#include "CLHEP/Vector/LorentzVector.h"
34
35namespace CLHEP {
36
37// Declarations of classes and global methods
38class HepRotation;
39inline HepRotation inverseOf ( const HepRotation & r );
40inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r);
41inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r);
42inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r);
43
49
50public:
51
52 // ---------- Constructors and Assignment:
53
54 inline HepRotation();
55 // Default constructor. Gives a unit matrix.
56
57 inline HepRotation(const HepRotation & m);
58 // Copy constructor.
59
60 inline HepRotation(const HepRotationX & m);
61 inline HepRotation(const HepRotationY & m);
62 inline HepRotation(const HepRotationZ & m);
63 // Construct from specialized rotation.
64
65 HepRotation & set( const Hep3Vector & axis, double delta );
66 HepRotation ( const Hep3Vector & axis, double delta );
67 // Construct from axis and angle.
68
69 HepRotation & set( const HepAxisAngle & ax );
70 HepRotation ( const HepAxisAngle & ax );
71 // Construct from AxisAngle structure.
72
73 HepRotation & set( double phi, double theta, double psi );
74 HepRotation ( double phi, double theta, double psi );
75 // Construct from three Euler angles (in radians).
76
77 HepRotation & set( const HepEulerAngles & e );
78 HepRotation ( const HepEulerAngles & e );
79 // Construct from EulerAngles structure.
80
81 HepRotation ( const Hep3Vector & colX,
82 const Hep3Vector & colY,
83 const Hep3Vector & colZ );
84 // Construct from three *orthogonal* unit vector columns.
85 // NOTE:
86 // This constructor, and the two set methods below,
87 // will check that the columns (or rows) form an orthonormal
88 // matrix, and will adjust values so that this relation is
89 // as exact as possible.
90
91 HepRotation & set( const Hep3Vector & colX,
92 const Hep3Vector & colY,
93 const Hep3Vector & colZ );
94 // supply three *orthogonal* unit vectors for the columns.
95
97 const Hep3Vector & rowY,
98 const Hep3Vector & rowZ );
99 // supply three *orthogonal* unit vectors for the rows.
100
101 inline HepRotation & set(const HepRotationX & r);
102 inline HepRotation & set(const HepRotationY & r);
103 inline HepRotation & set(const HepRotationZ & r);
104 // set from specialized rotation.
105
107 // Assignment.
108
112 // Assignment from specialized rotation.
113
114 inline HepRotation &set( const HepRep3x3 & m );
115 inline HepRotation ( const HepRep3x3 & m );
116 // WARNING - NO CHECKING IS DONE!
117 // Constructon directly from from a 3x3 representation,
118 // which is required to be an orthogonal matrix.
119
120 inline ~HepRotation();
121 // Trivial destructor.
122
123 // ---------- Accessors:
124
125 inline Hep3Vector colX() const;
126 inline Hep3Vector colY() const;
127 inline Hep3Vector colZ() const;
128 // orthogonal unit-length column vectors
129
130 inline Hep3Vector rowX() const;
131 inline Hep3Vector rowY() const;
132 inline Hep3Vector rowZ() const;
133 // orthogonal unit-length row vectors
134
135 inline double xx() const;
136 inline double xy() const;
137 inline double xz() const;
138 inline double yx() const;
139 inline double yy() const;
140 inline double yz() const;
141 inline double zx() const;
142 inline double zy() const;
143 inline double zz() const;
144 // Elements of the rotation matrix (Geant4).
145
146 inline HepRep3x3 rep3x3() const;
147 // 3x3 representation:
148
149 // ------------ Subscripting:
150
152 public:
153 inline HepRotation_row(const HepRotation &, int);
154 inline double operator [] (int) const;
155 private:
156 const HepRotation & rr;
157 int ii;
158 };
159 // Helper class for implemention of C-style subscripting r[i][j]
160
161 inline const HepRotation_row operator [] (int) const;
162 // Returns object of the helper class for C-style subscripting r[i][j]
163 // i and j range from 0 to 2.
164
165 double operator () (int, int) const;
166 // Fortran-style subscripting: returns (i,j) element of the rotation matrix.
167 // Note: i and j still range from 0 to 2. [Rotation.cc]
168
169 // ------------ Euler angles:
170 inline double getPhi () const;
171 inline double getTheta() const;
172 inline double getPsi () const;
173 double phi () const;
174 double theta() const;
175 double psi () const;
177
178 // ------------ axis & angle of rotation:
179 inline double getDelta() const;
180 inline Hep3Vector getAxis () const;
181 double delta() const;
182 Hep3Vector axis () const;
183 HepAxisAngle axisAngle() const;
184 void getAngleAxis(double & delta, Hep3Vector & axis) const;
185 // Returns the rotation angle and rotation axis (Geant4). [Rotation.cc]
186
187 // ------------- Angles of rotated axes
188 double phiX() const;
189 double phiY() const;
190 double phiZ() const;
191 double thetaX() const;
192 double thetaY() const;
193 double thetaZ() const;
194 // Return angles (RADS) made by rotated axes against original axes (Geant4).
195 // [Rotation.cc]
196
197 // ---------- Other accessors treating pure rotation as a 4-rotation
198
199 inline HepLorentzVector col1() const;
200 inline HepLorentzVector col2() const;
201 inline HepLorentzVector col3() const;
202 // orthosymplectic 4-vector columns - T component will be zero
203
204 inline HepLorentzVector col4() const;
205 // Will be (0,0,0,1) for this pure Rotation.
206
207 inline HepLorentzVector row1() const;
208 inline HepLorentzVector row2() const;
209 inline HepLorentzVector row3() const;
210 // orthosymplectic 4-vector rows - T component will be zero
211
212 inline HepLorentzVector row4() const;
213 // Will be (0,0,0,1) for this pure Rotation.
214
215 inline double xt() const;
216 inline double yt() const;
217 inline double zt() const;
218 inline double tx() const;