CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
Rotation.icc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: Rotation.icc,v 1.2 2003/10/10 21:42:35 garren Exp $
3// ---------------------------------------------------------------------------
4//
5// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6//
7// This is the definitions of the inline member functions of the
8// HepRotation class
9//
10
11namespace CLHEP {
12
13// Put commonly used accessors as early as possible to avoid inlining misses:
14
15inline double HepRotation::xx() const { return rxx; }
16inline double HepRotation::xy() const { return rxy; }
17inline double HepRotation::xz() const { return rxz; }
18inline double HepRotation::yx() const { return ryx; }
19inline double HepRotation::yy() const { return ryy; }
20inline double HepRotation::yz() const { return ryz; }
21inline double HepRotation::zx() const { return rzx; }
22inline double HepRotation::zy() const { return rzy; }
23inline double HepRotation::zz() const { return rzz; }
24
26 return HepRep3x3 ( rxx, rxy, rxz,
27 ryx, ryy, ryz,
28 rzx, rzy, rzz );
29}
30
31inline double HepRotation::xt() const { return 0.0; }
32inline double HepRotation::yt() const { return 0.0; }
33inline double HepRotation::zt() const { return 0.0; }
34inline double HepRotation::tx() const { return 0.0; }
35inline double HepRotation::ty() const { return 0.0; }
36inline double HepRotation::tz() const { return 0.0; }
37inline double HepRotation::tt() const { return 1.0; }
38
40 return HepRep4x4 ( rxx, rxy, rxz, 0.0,
41 ryx, ryy, ryz, 0.0,
42 rzx, rzy, rzz, 0.0,
43 0.0, 0.0, 0.0, 1.0 );
44}
45
46// Ctors etc:
47
48inline HepRotation::HepRotation() : rxx(1.0), rxy(0.0), rxz(0.0),
49 ryx(0.0), ryy(1.0), ryz(0.0),
50 rzx(0.0), rzy(0.0), rzz(1.0) {}
51
53 rxx(m1.rxx), rxy(m1.rxy), rxz(m1.rxz),
54 ryx(m1.ryx), ryy(m1.ryy), ryz(m1.ryz),
55 rzx(m1.rzx), rzy(m1.rzy), rzz(m1.rzz) {}
56
58 (double mxx, double mxy, double mxz,
59 double myx, double myy, double myz,
60 double mzx, double mzy, double mzz) :
61 rxx(mxx), rxy(mxy), rxz(mxz),
62 ryx(myx), ryy(myy), ryz(myz),
63 rzx(mzx), rzy(mzy), rzz(mzz) {}
64
65inline HepRotation::HepRotation ( const HepRep3x3 & m1 ) :
66 rxx(m1.xx_), rxy(m1.xy_), rxz(m1.xz_),
67 ryx(m1.yx_), ryy(m1.yy_), ryz(m1.yz_),
68 rzx(m1.zx_), rzy(m1.zy_), rzz(m1.zz_) {}
69
71 rxx(1.0), rxy(0.0), rxz(0.0),
72 ryx(0.0), ryy(rx.yy()), ryz(rx.yz()),
73 rzx(0.0), rzy(rx.zy()), rzz(rx.zz()) {}
74
76 rxx(ry.xx()), rxy(0.0), rxz(ry.xz()),
77 ryx(0.0), ryy(1.0), ryz(0.0),
78 rzx(ry.zx()), rzy(0.0), rzz(ry.zz()) {}
79
81 rxx(rz.xx()), rxy(rz.xy()), rxz(0.0),
82 ryx(rz.yx()), ryy(rz.yy()), ryz(0.0),
83 rzx(0.0), rzy(0.0), rzz(1.0) {}
84
86
87// More accessors:
88
90(const HepRotation & r, int i) : rr(r), ii(i) {}
91
92inline double HepRotation::HepRotation_row::operator [] (int jj) const {
93 return rr(ii,jj);
94}
95
96inline
98 return HepRotation_row(*this, i);
99}
100
102 { return Hep3Vector ( rxx, ryx, rzx ); }
104 { return Hep3Vector ( rxy, ryy, rzy ); }
106 { return Hep3Vector ( rxz, ryz, rzz ); }
107
109 { return Hep3Vector ( rxx, rxy, rxz ); }
111 { return Hep3Vector ( ryx, ryy, ryz ); }
113 { return Hep3Vector ( rzx, rzy, rzz ); }
114
116 { return HepLorentzVector (colX(), 0); }
118 { return HepLorentzVector (colY(), 0); }
120 { return HepLorentzVector (colZ(), 0); }
122 { return HepLorentzVector (0,0,0,1); }
124 { return HepLorentzVector (rowX(), 0); }
126 { return HepLorentzVector (rowY(), 0); }
128 { return HepLorentzVector (rowZ(), 0); }
130 { return HepLorentzVector (0,0,0,1); }
131
132inline double HepRotation::getPhi () const { return phi(); }
133inline double HepRotation::getTheta() const { return theta(); }
134inline double HepRotation::getPsi () const { return psi(); }
135inline double HepRotation::getDelta() const { return delta(); }
136inline Hep3Vector HepRotation::getAxis () const { return axis(); }
137
139 rxx = m1.rxx;
140 rxy = m1.rxy;
141 rxz = m1.rxz;
142 ryx = m1.ryx;
143 ryy = m1.ryy;
144 ryz = m1.ryz;
145 rzx = m1.rzx;
146 rzy = m1.rzy;
147 rzz = m1.rzz;
148 return *this;
149}
150
152 rxx = m1.xx_;
153 rxy = m1.xy_;
154 rxz = m1.xz_;
155 ryx = m1.yx_;
156 ryy = m1.yy_;
157 ryz = m1.yz_;
158 rzx = m1.zx_;
159 rzy = m1.zy_;
160 rzz = m1.zz_;
161 return *this;
162}
163
165 return (set (r.rep3x3()));
166}
168 return (set (r.rep3x3()));
169}
171 return (set (r.rep3x3()));
172}
173
175 return (set (r.rep3x3()));
176}
178 return (set (r.rep3x3()));
179}
181 return (set (r.rep3x3()));
182}
183
185 return Hep3Vector(rxx*p.x() + rxy*p.y() + rxz*p.z(),
186 ryx*p.x() + ryy*p.y() + ryz*p.z(),
187 rzx*p.x() + rzy*p.y() + rzz*p.z());
188// This is identical to the code in the CLHEP 1.6 version
189}
190
192 double x = p.x();
193 double y = p.y();
194 double z = p.z();
195 return Hep3Vector(rxx*x + rxy*y + rxz*z,
196 ryx*x + ryy*y + ryz*z,
197 rzx*x + rzy*y + rzz*z);
198}
199
200inline HepLorentzVector
202 return HepLorentzVector( operator() (w.vect()), w.t() );
203}
204
205inline HepLorentzVector HepRotation::operator *
206 (const HepLorentzVector & p) const {
207 return operator()(p);
208}
209
211 return HepRotation(rxx*r.rxx + rxy*r.ryx + rxz*r.rzx,
212 rxx*r.rxy + rxy*r.ryy + rxz*r.rzy,
213 rxx*r.rxz + rxy*r.ryz + rxz*r.rzz,
214 ryx*r.rxx + ryy*r.ryx + ryz*r.rzx,
215 ryx*r.rxy + ryy*r.ryy + ryz*r.rzy,
216 ryx*r.rxz + ryy*r.ryz + ryz*r.rzz,
217 rzx*r.rxx + rzy*r.ryx + rzz*r.rzx,
218 rzx*r.rxy + rzy*r.ryy + rzz*r.rzy,
219 rzx*r.rxz + rzy*r.ryz + rzz*r.rzz );
220}
221
223 double yy1 = rx.yy();
224 double yz1 = rx.yz();
225 double zy1 = -yz1;
226 double zz1 = yy1;
227 return HepRotation(
228 rxx, rxy*yy1 + rxz*zy1, rxy*yz1 + rxz*zz1,
229 ryx, ryy*yy1 + ryz*zy1, ryy*yz1 + ryz*zz1,
230 rzx, rzy*yy1 + rzz*zy1, rzy*yz1 + rzz*zz1 );
231}
232
234 double xx1 = ry.xx();
235 double xz1 = ry.xz();
236 double zx1 = -xz1;
237 double zz1 = xx1;
238 return HepRotation(
239 rxx*xx1 + rxz*zx1, rxy, rxx*xz1 + rxz*zz1,
240 ryx*xx1 + ryz*zx1, ryy, ryx*xz1 + ryz*zz1,
241 rzx*xx1 + rzz*zx1, rzy, rzx*xz1 + rzz*zz1 );
242}
243
245 double xx1 = rz.xx();
246 double xy1 = rz.xy();
247 double yx1 = -xy1;
248 double yy1 = xx1;
249 return HepRotation(
250 rxx*xx1 + rxy*yx1, rxx*xy1 + rxy*yy1, rxz,
251 ryx*xx1 + ryy*yx1, ryx*xy1 + ryy*yy1, ryz,
252 rzx*xx1 + rzy*yx1, rzx*xy1 + rzy*yy1, rzz );
253}
254
255
257 return *this = (*this) * (r);
258}
259
261 return *this = (*this) * (r); }
263 return *this = (*this) * (r); }
265 return *this = (*this) * (r); }
266
268 return *this = r * (*this);
269}
270
272 return *this = r * (*this); }
274 return *this = r * (*this); }
276 return *this = r * (*this); }
277
279 return HepRotation( rxx, ryx, rzx,
280 rxy, ryy, rzy,
281 rxz, ryz, rzz );
282}
283
285 return r.inverse();
286}
287
289 return *this=inverse();
290}
291
293 (double ddelta, const Hep3Vector * p) {
294 return rotate(ddelta, *p);
295}
296
297inline bool HepRotation::operator== ( const HepRotation & r ) const {
298 return ( rxx==r.rxx && rxy==r.rxy && rxz==r.rxz &&
299 ryx==r.ryx && ryy==r.ryy && ryz==r.ryz &&
300 rzx==r.rzx && rzy==r.rzy && rzz==r.rzz );
301}
302inline bool HepRotation::operator!= ( const HepRotation & r ) const {
303 return ! operator==(r);
304}
305inline bool HepRotation::operator< ( const HepRotation & r ) const
306 { return compare(r)< 0; }
307inline bool HepRotation::operator<=( const HepRotation & r ) const
308 { return compare(r)<=0; }
309inline bool HepRotation::operator>=( const HepRotation & r ) const
310 { return compare(r)>=0; }
311inline bool HepRotation::operator> ( const HepRotation & r ) const
312 { return compare(r)> 0; }
313
317inline double HepRotation::setTolerance(double tol) {
319}
320
321inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r){
322 HepRep3x3 mmm = r.rep3x3();
323 double c = rx.yy();
324 double ss = rx.zy();
325 return HepRotation ( mmm.xx_, mmm.xy_, mmm.xz_,
326 c*mmm.yx_-ss*mmm.zx_, c*mmm.yy_-ss*mmm.zy_, c*mmm.yz_-ss*mmm.zz_,
327 ss*mmm.yx_+c*mmm.zx_, ss*mmm.yy_+c*mmm.zy_, ss*mmm.yz_+c*mmm.zz_ );
328}
329
330inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r){
331 HepRep3x3 mmm = r.rep3x3();
332 double c = ry.xx();
333 double ss = ry.xz();
334 return HepRotation ( c*mmm.xx_+ss*mmm.zx_, c*mmm.xy_+ss*mmm.zy_, c*mmm.xz_+ss*mmm.zz_,
335 mmm.yx_, mmm.yy_, mmm.yz_,
336 -ss*mmm.xx_+c*mmm.zx_,-ss*mmm.xy_+c*mmm.zy_,-ss*mmm.xz_+c*mmm.zz_ );
337}
338
339inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r){
340 HepRep3x3 mmm = r.rep3x3();
341 double c = rz.xx();
342 double ss = rz.yx();
343 return HepRotation ( c*mmm.xx_-ss*mmm.yx_, c*mmm.xy_-ss*mmm.yy_, c*mmm.xz_-ss*mmm.yz_,
344 ss*mmm.xx_+c*mmm.yx_, ss*mmm.xy_+c*mmm.yy_, ss*mmm.xz_+c*mmm.yz_,
345 mmm.zx_, mmm.zy_, mmm.zz_ );
346}
347
348} // namespace CLHEP
double z() const
double x() const
double y() const
static double setTolerance(double tol)
Hep3Vector vect() const
double yz() const
Definition RotationX.icc:16
double zy() const
Definition RotationX.icc:17
HepRep3x3 rep3x3() const
Definition RotationX.icc:26
double yy() const
Definition RotationX.icc:15
double xx() const
Definition RotationY.icc:15
double xz() const
Definition RotationY.icc:16
HepRep3x3 rep3x3() const
Definition RotationY.icc:26
double xy() const
Definition RotationZ.icc:16
HepRep3x3 rep3x3() const
Definition RotationZ.icc:26
double xx() const
Definition RotationZ.icc:15
double yx() const
Definition RotationZ.icc:17
HepRotation_row(const HepRotation &, int)
Definition Rotation.icc:90
double operator()(int, int) const
Hep3Vector operator*(const Hep3Vector &p) const
Definition Rotation.icc:184
double getPsi() const
Definition Rotation.icc:134
double getPhi() const
Definition Rotation.icc:132
double zz() const
Definition Rotation.icc:23
double yz() const
Definition Rotation.icc:20
Hep3Vector colX() const
Definition Rotation.icc:101
bool operator==(const HepRotation &r) const
Definition Rotation.icc:297
bool operator!=(const HepRotation &r) const
Definition Rotation.icc:302
HepLorentzVector col3() const
Definition Rotation.icc:119
double zx() const
Definition Rotation.icc:21
Hep3Vector axis() const
double phi() const
HepRotation inverse() const
Definition Rotation.icc:278
double tz() const
Definition Rotation.icc:36
HepRotation & rotate(double delta, const Hep3Vector &axis)
Hep3Vector rowY() const
Definition Rotation.icc:110
Hep3Vector colY() const
Definition Rotation.icc:103
Hep3Vector getAxis() const
Definition Rotation.icc:136
HepRotation & operator*=(const HepRotation &r)
Definition Rotation.icc:256
double ty() const
Definition Rotation.icc:35
HepLorentzVector col1() const
Definition Rotation.icc:115
double delta() const
HepLorentzVector col2() const
Definition Rotation.icc:117
HepLorentzVector col4() const
Definition Rotation.icc:121
double tx() const
Definition Rotation.icc:34
HepRotation & transform(const HepRotation &r)
Definition Rotation.icc:267
double yx() const
Definition Rotation.icc:18
HepRep3x3 rep3x3() const
Definition Rotation.icc:25
double zy() const
Definition Rotation.icc:22
HepRep4x4 rep4x4() const
Definition Rotation.icc:39
HepLorentzVector row1() const
Definition Rotation.icc:123
bool operator>(const HepRotation &r) const
Definition Rotation.icc:311
static double setTolerance(double tol)
Definition Rotation.icc:317
double zt() const
Definition Rotation.icc:33
HepRotation & set(const Hep3Vector &axis, double delta)
HepRotation & operator=(const HepRotation &r)
Definition Rotation.icc:138
Hep3Vector colZ() const
Definition Rotation.icc:105
double xx() const
Definition Rotation.icc:15
HepLorentzVector row2() const
Definition Rotation.icc:125
double psi() const
Hep3Vector rowX() const
Definition Rotation.icc:108
double theta() const
double tt() const
Definition Rotation.icc:37
double yy() const
Definition Rotation.icc:19
double xz() const
Definition Rotation.icc:17
HepLorentzVector row3() const
Definition Rotation.icc:127
double yt() const
Definition Rotation.icc:32
Hep3Vector rowZ() const
Definition Rotation.icc:112
const HepRotation_row operator[](int) const
Definition Rotation.icc:97
double getTheta() const
Definition Rotation.icc:133
bool operator<(const HepRotation &r) const
Definition Rotation.icc:305
HepLorentzVector row4() const
Definition Rotation.icc:129
static double getTolerance()
Definition Rotation.icc:314
int compare(const HepRotation &r) const
HepRotation & invert()
Definition Rotation.icc:288
double xy() const
Definition Rotation.icc:16
bool operator>=(const HepRotation &r) const
Definition Rotation.icc:309
bool operator<=(const HepRotation &r) const
Definition Rotation.icc:307
double getDelta() const
Definition Rotation.icc:135
double xt() const
Definition Rotation.icc:31
HepBoost inverseOf(const HepBoost &lt)
Definition Boost.icc:266