Geant4  10.02.p02
LorentzRotation.icc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:$
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 // HepLorentzRotation class
9 //
10 
11 namespace CLHEP {
12 
13 // ---------- Constructors and Assignment:
14 
15 inline HepLorentzRotation::HepLorentzRotation() :
16  mxx(1.0), mxy(0.0), mxz(0.0), mxt(0.0),
17  myx(0.0), myy(1.0), myz(0.0), myt(0.0),
18  mzx(0.0), mzy(0.0), mzz(1.0), mzt(0.0),
19  mtx(0.0), mty(0.0), mtz(0.0), mtt(1.0) {}
20 
21 inline HepLorentzRotation::HepLorentzRotation(const HepLorentzRotation & r) :
22  mxx(r.mxx), mxy(r.mxy), mxz(r.mxz), mxt(r.mxt),
23  myx(r.myx), myy(r.myy), myz(r.myz), myt(r.myt),
24  mzx(r.mzx), mzy(r.mzy), mzz(r.mzz), mzt(r.mzt),
25  mtx(r.mtx), mty(r.mty), mtz(r.mtz), mtt(r.mtt) {}
26 
27 inline HepLorentzRotation::HepLorentzRotation(const HepRotation & r) {
28  set (r.rep4x4());
29 }
30 inline HepLorentzRotation::HepLorentzRotation(const HepRotationX & r) {
31  set (r.rep4x4());
32 }
33 inline HepLorentzRotation::HepLorentzRotation(const HepRotationY & r) {
34  set (r.rep4x4());
35 }
36 inline HepLorentzRotation::HepLorentzRotation(const HepRotationZ & r) {
37  set (r.rep4x4());
38 }
39 
40 inline HepLorentzRotation::HepLorentzRotation(const HepBoost & b) {
41  set (b.rep4x4());
42 }
43 inline HepLorentzRotation::HepLorentzRotation(const HepBoostX & b) {
44  set (b.rep4x4());
45 }
46 inline HepLorentzRotation::HepLorentzRotation(const HepBoostY & b) {
47  set (b.rep4x4());
48 }
49 inline HepLorentzRotation::HepLorentzRotation(const HepBoostZ & b) {
50  set (b.rep4x4());
51 }
52 
53 inline HepLorentzRotation &
54 HepLorentzRotation::operator = (const HepLorentzRotation & r) {
55  mxx = r.mxx; mxy = r.mxy; mxz = r.mxz; mxt = r.mxt;
56  myx = r.myx; myy = r.myy; myz = r.myz; myt = r.myt;
57  mzx = r.mzx; mzy = r.mzy; mzz = r.mzz; mzt = r.mzt;
58  mtx = r.mtx; mty = r.mty; mtz = r.mtz; mtt = r.mtt;
59  return *this;
60 }
61 
62 inline HepLorentzRotation &
63 HepLorentzRotation::operator = (const HepRotation & m1) {
64  return set (m1.rep4x4());
65 }
66 
67 inline HepLorentzRotation &
68 HepLorentzRotation::operator = (const HepBoost & m1) {
69  return set (m1.rep4x4());
70 }
71 
72 HepLorentzRotation & HepLorentzRotation::set (const Hep3Vector & p) {
73  return set (p.x(), p.y(), p.z());
74 }
75 
76 inline HepLorentzRotation & HepLorentzRotation::set (const HepRotation & r) {
77  return set (r.rep4x4());
78 }
79 inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationX & r) {
80  return set (r.rep4x4());
81 }
82 inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationY & r) {
83  return set (r.rep4x4());
84 }
85 inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationZ & r) {
86  return set (r.rep4x4());
87 }
88 
89 inline HepLorentzRotation & HepLorentzRotation::set (const HepBoost & bboost) {
90  return set (bboost.rep4x4());
91 }
92 inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostX & bboost) {
93  return set (bboost.rep4x4());
94 }
95 inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostY & bboost) {
96  return set (bboost.rep4x4());
97 }
98 inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostZ & bboost) {
99  return set (bboost.rep4x4());
100 }
101 
102 inline HepLorentzRotation::HepLorentzRotation(double bx,
103  double by,
104  double bz)
105 {
106  set(bx, by, bz);
107 }
108 
109 inline HepLorentzRotation::HepLorentzRotation(const Hep3Vector & p)
110 {
111  set(p.x(), p.y(), p.z());
112 }
113 
114 inline HepLorentzRotation::HepLorentzRotation(
115  const HepBoost & B, const HepRotation & R)
116 {
117  set(B, R);
118 }
119 
120 inline HepLorentzRotation::HepLorentzRotation(
121  const HepRotation & R, const HepBoost & B)
122 {
123  set(R, B);
124 }
125 
126 inline HepLorentzRotation & HepLorentzRotation::set( const HepRep4x4 & rep ) {
127  mxx=rep.xx_; mxy=rep.xy_; mxz=rep.xz_; mxt=rep.xt_;
128  myx=rep.yx_; myy=rep.yy_; myz=rep.yz_; myt=rep.yt_;
129  mzx=rep.zx_; mzy=rep.zy_; mzz=rep.zz_; mzt=rep.zt_;
130  mtx=rep.tx_; mty=rep.ty_; mtz=rep.tz_; mtt=rep.tt_;
131  return *this;
132 }
133 
134 inline HepLorentzRotation ::HepLorentzRotation ( const HepRep4x4 & rep ) :
135  mxx(rep.xx_), mxy(rep.xy_), mxz(rep.xz_), mxt(rep.xt_),
136  myx(rep.yx_), myy(rep.yy_), myz(rep.yz_), myt(rep.yt_),
137  mzx(rep.zx_), mzy(rep.zy_), mzz(rep.zz_), mzt(rep.zt_),
138  mtx(rep.tx_), mty(rep.ty_), mtz(rep.tz_), mtt(rep.tt_) {}
139 
140 // - Protected methods
141 
142 inline HepLorentzRotation::HepLorentzRotation(
143  double rxx, double rxy, double rxz, double rxt,
144  double ryx, double ryy, double ryz, double ryt,
145  double rzx, double rzy, double rzz, double rzt,
146  double rtx, double rty, double rtz, double rtt) :
147  mxx(rxx), mxy(rxy), mxz(rxz), mxt(rxt),
148  myx(ryx), myy(ryy), myz(ryz), myt(ryt),
149  mzx(rzx), mzy(rzy), mzz(rzz), mzt(rzt),
150  mtx(rtx), mty(rty), mtz(rtz), mtt(rtt) {}
151 
152 inline void HepLorentzRotation::setBoost
153  (double bx, double by, double bz) {
154  set(bx, by, bz);
155 }
156 
157 // ---------- Accessors:
158 
159 inline double HepLorentzRotation::xx() const { return mxx; }
160 inline double HepLorentzRotation::xy() const { return mxy; }
161 inline double HepLorentzRotation::xz() const { return mxz; }
162 inline double HepLorentzRotation::xt() const { return mxt; }
163 inline double HepLorentzRotation::yx() const { return myx; }
164 inline double HepLorentzRotation::yy() const { return myy; }
165 inline double HepLorentzRotation::yz() const { return myz; }
166 inline double HepLorentzRotation::yt() const { return myt; }
167 inline double HepLorentzRotation::zx() const { return mzx; }
168 inline double HepLorentzRotation::zy() const { return mzy; }
169 inline double HepLorentzRotation::zz() const { return mzz; }
170 inline double HepLorentzRotation::zt() const { return mzt; }
171 inline double HepLorentzRotation::tx() const { return mtx; }
172 inline double HepLorentzRotation::ty() const { return mty; }
173 inline double HepLorentzRotation::tz() const { return mtz; }
174 inline double HepLorentzRotation::tt() const { return mtt; }
175 
176 inline HepLorentzVector HepLorentzRotation::col1() const {
177  return HepLorentzVector ( mxx, myx, mzx, mtx );
178 }
179 inline HepLorentzVector HepLorentzRotation::col2() const {
180  return HepLorentzVector ( mxy, myy, mzy, mty );
181 }
182 inline HepLorentzVector HepLorentzRotation::col3() const {
183  return HepLorentzVector ( mxz, myz, mzz, mtz );
184 }
185 inline HepLorentzVector HepLorentzRotation::col4() const {
186  return HepLorentzVector ( mxt, myt, mzt, mtt );
187 }
188 
189 inline HepLorentzVector HepLorentzRotation::row1() const {
190  return HepLorentzVector ( mxx, mxy, mxz, mxt );
191 }
192 inline HepLorentzVector HepLorentzRotation::row2() const {
193  return HepLorentzVector ( myx, myy, myz, myt );
194 }
195 inline HepLorentzVector HepLorentzRotation::row3() const {
196  return HepLorentzVector ( mzx, mzy, mzz, mzt );
197 }
198 inline HepLorentzVector HepLorentzRotation::row4() const {
199  return HepLorentzVector ( mtx, mty, mtz, mtt );
200 }
201 
202 inline HepRep4x4 HepLorentzRotation::rep4x4() const {
203  return HepRep4x4( mxx, mxy, mxz, mxt,
204  myx, myy, myz, myt,
205  mzx, mzy, mzz, mzt,
206  mtx, mty, mtz, mtt );
207 }
208 
209 
210 // ------------ Subscripting:
211 
212 inline HepLorentzRotation::HepLorentzRotation_row::HepLorentzRotation_row
213 (const HepLorentzRotation & r, int i) : rr(r), ii(i) {}
214 
215 inline double
216 HepLorentzRotation::HepLorentzRotation_row::operator [] (int jj) const {
217  return rr(ii,jj);
218 }
219 
220 inline const HepLorentzRotation::HepLorentzRotation_row
221 HepLorentzRotation::operator [] (int i) const {
222  return HepLorentzRotation_row(*this, i);
223 }
224 
225 // ---------- Comparisons:
226 
227 inline bool
228 HepLorentzRotation::operator == (const HepLorentzRotation & r) const {
229  return (mxx == r.xx() && mxy == r.xy() && mxz == r.xz() && mxt == r.xt() &&
230  myx == r.yx() && myy == r.yy() && myz == r.yz() && myt == r.yt() &&
231  mzx == r.zx() && mzy == r.zy() && mzz == r.zz() && mzt == r.zt() &&
232  mtx == r.tx() && mty == r.ty() && mtz == r.tz() && mtt == r.tt());
233 }
234 
235 inline bool
236 HepLorentzRotation::operator != (const HepLorentzRotation & r) const {
237  return ! operator==(r);
238 }
239 
240 inline bool
241 HepLorentzRotation::operator < ( const HepLorentzRotation & r ) const
242  { return compare(r)< 0; }
243 inline bool
244 HepLorentzRotation::operator <= ( const HepLorentzRotation & r ) const
245  { return compare(r)<=0; }
246 
247 inline bool
248 HepLorentzRotation::operator >= ( const HepLorentzRotation & r ) const
249  { return compare(r)>=0; }
250 inline bool
251 HepLorentzRotation::operator > ( const HepLorentzRotation & r ) const
252  { return compare(r)> 0; }
253 
254 inline bool HepLorentzRotation::isIdentity() const {
255  return (mxx == 1.0 && mxy == 0.0 && mxz == 0.0 && mxt == 0.0 &&
256  myx == 0.0 && myy == 1.0 && myz == 0.0 && myt == 0.0 &&
257  mzx == 0.0 && mzy == 0.0 && mzz == 1.0 && mzt == 0.0 &&
258  mtx == 0.0 && mty == 0.0 && mtz == 0.0 && mtt == 1.0);
259 }
260 
261 // ---------- Properties:
262 
263 // ---------- Application:
264 
265 inline HepLorentzVector
266 HepLorentzRotation::vectorMultiplication(const HepLorentzVector & p) const {
267  double x(p.x());
268  double y(p.y());
269  double z(p.z());
270  double t(p.t());
271  return HepLorentzVector(mxx*x + mxy*y + mxz*z + mxt*t,
272  myx*x + myy*y + myz*z + myt*t,
273  mzx*x + mzy*y + mzz*z + mzt*t,
274  mtx*x + mty*y + mtz*z + mtt*t);
275 }
276 
277 inline HepLorentzVector
278 HepLorentzRotation::operator() (const HepLorentzVector & w) const {
279  return vectorMultiplication(w);
280 }
281 
282 inline HepLorentzVector
283 HepLorentzRotation::operator * (const HepLorentzVector & p) const {
284  return vectorMultiplication(p);
285 }
286 
287 // ---------- Operations in the group of 4-Rotations
288 
289 inline HepLorentzRotation
290 HepLorentzRotation::operator * (const HepBoost & b) const {
291  return matrixMultiplication(b.rep4x4());
292 }
293 inline HepLorentzRotation
294 HepLorentzRotation::operator * (const HepRotation & r) const {
295  return matrixMultiplication(r.rep4x4());
296 }
297 inline HepLorentzRotation
298 HepLorentzRotation::operator * (const HepLorentzRotation & lt) const {
299  return matrixMultiplication(lt.rep4x4());
300 }
301 
302 inline HepLorentzRotation &
303 HepLorentzRotation::operator *= (const HepBoost & b) {
304  return *this = matrixMultiplication(b.rep4x4());
305 }
306 inline HepLorentzRotation &
307 HepLorentzRotation::operator *= (const HepRotation & r) {
308  return *this = matrixMultiplication(r.rep4x4());
309 }
310 inline HepLorentzRotation &
311 HepLorentzRotation::operator *= (const HepLorentzRotation & lt) {
312  return *this = matrixMultiplication(lt.rep4x4());
313 }
314 
315 inline HepLorentzRotation &
316 HepLorentzRotation::transform (const HepBoost & b) {
317  return *this = HepLorentzRotation(b).matrixMultiplication(rep4x4());
318 }
319 inline HepLorentzRotation &
320 HepLorentzRotation::transform (const HepRotation & r) {
321  return *this = HepLorentzRotation(r).matrixMultiplication(rep4x4());
322 }
323 inline HepLorentzRotation &
324 HepLorentzRotation::transform (const HepLorentzRotation & lt) {
325  return *this = lt.matrixMultiplication(rep4x4());
326 }
327 
328 inline HepLorentzRotation &
329 HepLorentzRotation::rotate(double angle, const Hep3Vector & axis) {
330  return transform(HepRotation().rotate(angle, axis));
331 }
332 
333 inline HepLorentzRotation &
334 HepLorentzRotation::rotate(double angle, const Hep3Vector * axis) {
335  return transform(HepRotation().rotate(angle, axis));
336 }
337 
338 inline HepLorentzRotation &
339 HepLorentzRotation::boost(double bx, double by, double bz) {
340  return transform(HepLorentzRotation(bx, by, bz));
341 }
342 
343 inline HepLorentzRotation &
344 HepLorentzRotation::boost(const Hep3Vector & b) {
345  return transform(HepLorentzRotation(b));
346 }
347 
348 inline HepLorentzRotation HepLorentzRotation::inverse() const {
349  return HepLorentzRotation( mxx, myx, mzx, -mtx,
350  mxy, myy, mzy, -mty,
351  mxz, myz, mzz, -mtz,
352  -mxt, -myt, -mzt, mtt );
353 }
354 
355 inline HepLorentzRotation & HepLorentzRotation::invert() {
356  return *this = inverse();
357 }
358 
359 inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt ) {
360  return HepLorentzRotation(
361  HepRep4x4(
362  lt.mxx, lt.myx, lt.mzx, -lt.mtx,
363  lt.mxy, lt.myy, lt.mzy, -lt.mty,
364  lt.mxz, lt.myz, lt.mzz, -lt.mtz,
365  -lt.mxt, -lt.myt, -lt.mzt, lt.mtt ) );
366 }
367 
368 inline double HepLorentzRotation::getTolerance() {
369  return Hep4RotationInterface::tolerance;
370 }
371 inline double HepLorentzRotation::setTolerance(double tol) {
372  return Hep4RotationInterface::setTolerance(tol);
373 }
374 
375 } // namespace CLHEP