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