source: trunk/CLHEP/Vector/LorentzRotation.icc@ 16

Last change on this file since 16 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 12.2 KB
Line 
1// -*- C++ -*-
2// $Id: LorentzRotation.icc,v 1.1 2008-06-04 14:14:58 demin 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// HepLorentzRotation class
9//
10
11namespace CLHEP {
12
13// ---------- Constructors and Assignment:
14
15inline 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
21inline 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
27inline HepLorentzRotation::HepLorentzRotation(const HepRotation & r) {
28 set (r.rep4x4());
29}
30inline HepLorentzRotation::HepLorentzRotation(const HepRotationX & r) {
31 set (r.rep4x4());
32}
33inline HepLorentzRotation::HepLorentzRotation(const HepRotationY & r) {
34 set (r.rep4x4());
35}
36inline HepLorentzRotation::HepLorentzRotation(const HepRotationZ & r) {
37 set (r.rep4x4());
38}
39
40inline HepLorentzRotation::HepLorentzRotation(const HepBoost & b) {
41 set (b.rep4x4());
42}
43inline HepLorentzRotation::HepLorentzRotation(const HepBoostX & b) {
44 set (b.rep4x4());
45}
46inline HepLorentzRotation::HepLorentzRotation(const HepBoostY & b) {
47 set (b.rep4x4());
48}
49inline HepLorentzRotation::HepLorentzRotation(const HepBoostZ & b) {
50 set (b.rep4x4());
51}
52
53inline HepLorentzRotation &
54HepLorentzRotation::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
62inline HepLorentzRotation &
63HepLorentzRotation::operator = (const HepRotation & m) {
64 return set (m.rep4x4());
65}
66
67inline HepLorentzRotation &
68HepLorentzRotation::operator = (const HepBoost & m) {
69 return set (m.rep4x4());
70}
71
72HepLorentzRotation & HepLorentzRotation::set (const Hep3Vector & p) {
73 return set (p.x(), p.y(), p.z());
74}
75
76inline HepLorentzRotation & HepLorentzRotation::set (const HepRotation & r) {
77 return set (r.rep4x4());
78}
79inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationX & r) {
80 return set (r.rep4x4());
81}
82inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationY & r) {
83 return set (r.rep4x4());
84}
85inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationZ & r) {
86 return set (r.rep4x4());
87}
88
89inline HepLorentzRotation & HepLorentzRotation::set (const HepBoost & boost) {
90 return set (boost.rep4x4());
91}
92inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostX & boost) {
93 return set (boost.rep4x4());
94}
95inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostY & boost) {
96 return set (boost.rep4x4());
97}
98inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostZ & boost) {
99 return set (boost.rep4x4());
100}
101
102inline HepLorentzRotation::HepLorentzRotation(double bx,
103 double by,
104 double bz)
105{
106 set(bx, by, bz);
107}
108
109inline HepLorentzRotation::HepLorentzRotation(const Hep3Vector & p)
110{
111 set(p.x(), p.y(), p.z());
112}
113
114inline HepLorentzRotation::HepLorentzRotation(
115 const HepBoost & B, const HepRotation & R)
116{
117 set(B, R);
118}
119
120inline HepLorentzRotation::HepLorentzRotation(
121 const HepRotation & R, const HepBoost & B)
122{
123 set(R, B);
124}
125
126inline 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
134inline 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
142inline 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
152inline void HepLorentzRotation::setBoost
153 (double bx, double by, double bz) {
154 set(bx, by, bz);
155}
156
157// ---------- Accessors:
158
159inline double HepLorentzRotation::xx() const { return mxx; }
160inline double HepLorentzRotation::xy() const { return mxy; }
161inline double HepLorentzRotation::xz() const { return mxz; }
162inline double HepLorentzRotation::xt() const { return mxt; }
163inline double HepLorentzRotation::yx() const { return myx; }
164inline double HepLorentzRotation::yy() const { return myy; }
165inline double HepLorentzRotation::yz() const { return myz; }
166inline double HepLorentzRotation::yt() const { return myt; }
167inline double HepLorentzRotation::zx() const { return mzx; }
168inline double HepLorentzRotation::zy() const { return mzy; }
169inline double HepLorentzRotation::zz() const { return mzz; }
170inline double HepLorentzRotation::zt() const { return mzt; }
171inline double HepLorentzRotation::tx() const { return mtx; }
172inline double HepLorentzRotation::ty() const { return mty; }
173inline double HepLorentzRotation::tz() const { return mtz; }
174inline double HepLorentzRotation::tt() const { return mtt; }
175
176inline HepLorentzVector HepLorentzRotation::col1() const {
177 return HepLorentzVector ( mxx, myx, mzx, mtx );
178}
179inline HepLorentzVector HepLorentzRotation::col2() const {
180 return HepLorentzVector ( mxy, myy, mzy, mty );
181}
182inline HepLorentzVector HepLorentzRotation::col3() const {
183 return HepLorentzVector ( mxz, myz, mzz, mtz );
184}
185inline HepLorentzVector HepLorentzRotation::col4() const {
186 return HepLorentzVector ( mxt, myt, mzt, mtt );
187}
188
189inline HepLorentzVector HepLorentzRotation::row1() const {
190 return HepLorentzVector ( mxx, mxy, mxz, mxt );
191}
192inline HepLorentzVector HepLorentzRotation::row2() const {
193 return HepLorentzVector ( myx, myy, myz, myt );
194}
195inline HepLorentzVector HepLorentzRotation::row3() const {
196 return HepLorentzVector ( mzx, mzy, mzz, mzt );
197}
198inline HepLorentzVector HepLorentzRotation::row4() const {
199 return HepLorentzVector ( mtx, mty, mtz, mtt );
200}
201
202inline 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
212inline HepLorentzRotation::HepLorentzRotation_row::HepLorentzRotation_row
213(const HepLorentzRotation & r, int i) : rr(r), ii(i) {}
214
215inline double
216HepLorentzRotation::HepLorentzRotation_row::operator [] (int jj) const {
217 return rr(ii,jj);
218}
219
220inline const HepLorentzRotation::HepLorentzRotation_row
221HepLorentzRotation::operator [] (int i) const {
222 return HepLorentzRotation_row(*this, i);
223}
224
225// ---------- Comparisons:
226
227inline bool
228HepLorentzRotation::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
235inline bool
236HepLorentzRotation::operator != (const HepLorentzRotation & r) const {
237 return ! operator==(r);
238}
239
240inline bool
241HepLorentzRotation::operator < ( const HepLorentzRotation & r ) const
242 { return compare(r)< 0; }
243inline bool
244HepLorentzRotation::operator <= ( const HepLorentzRotation & r ) const
245 { return compare(r)<=0; }
246
247inline bool
248HepLorentzRotation::operator >= ( const HepLorentzRotation & r ) const
249 { return compare(r)>=0; }
250inline bool
251HepLorentzRotation::operator > ( const HepLorentzRotation & r ) const
252 { return compare(r)> 0; }
253
254inline 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
265inline HepLorentzVector
266HepLorentzRotation::vectorMultiplication(const HepLorentzVector & p) const {
267 register double x(p.x());
268 register double y(p.y());
269 register double z(p.z());
270 register 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
277inline HepLorentzVector
278HepLorentzRotation::operator() (const HepLorentzVector & w) const {
279 return vectorMultiplication(w);
280}
281
282inline HepLorentzVector
283HepLorentzRotation::operator * (const HepLorentzVector & p) const {
284 return vectorMultiplication(p);
285}
286
287// ---------- Operations in the group of 4-Rotations
288
289inline HepLorentzRotation
290HepLorentzRotation::operator * (const HepBoost & b) const {
291 return matrixMultiplication(b.rep4x4());
292}
293inline HepLorentzRotation
294HepLorentzRotation::operator * (const HepRotation & r) const {
295 return matrixMultiplication(r.rep4x4());
296}
297inline HepLorentzRotation
298HepLorentzRotation::operator * (const HepLorentzRotation & lt) const {
299 return matrixMultiplication(lt.rep4x4());
300}
301
302inline HepLorentzRotation &
303HepLorentzRotation::operator *= (const HepBoost & b) {
304 return *this = matrixMultiplication(b.rep4x4());
305}
306inline HepLorentzRotation &
307HepLorentzRotation::operator *= (const HepRotation & r) {
308 return *this = matrixMultiplication(r.rep4x4());
309}
310inline HepLorentzRotation &
311HepLorentzRotation::operator *= (const HepLorentzRotation & lt) {
312 return *this = matrixMultiplication(lt.rep4x4());
313}
314
315inline HepLorentzRotation &
316HepLorentzRotation::transform (const HepBoost & b) {
317 return *this = HepLorentzRotation(b).matrixMultiplication(rep4x4());
318}
319inline HepLorentzRotation &
320HepLorentzRotation::transform (const HepRotation & r) {
321 return *this = HepLorentzRotation(r).matrixMultiplication(rep4x4());
322}
323inline HepLorentzRotation &
324HepLorentzRotation::transform (const HepLorentzRotation & lt) {
325 return *this = lt.matrixMultiplication(rep4x4());
326}
327
328
329
330
331
332
333inline HepLorentzRotation &
334HepLorentzRotation::rotate(double angle, const Hep3Vector & axis) {
335 return transform(HepRotation().rotate(angle, axis));
336}
337
338inline HepLorentzRotation &
339HepLorentzRotation::rotate(double angle, const Hep3Vector * axis) {
340 return transform(HepRotation().rotate(angle, axis));
341}
342
343inline HepLorentzRotation &
344HepLorentzRotation::boost(double bx, double by, double bz) {
345 return transform(HepLorentzRotation(bx, by, bz));
346}
347
348inline HepLorentzRotation &
349HepLorentzRotation::boost(const Hep3Vector & b) {
350 return transform(HepLorentzRotation(b));
351}
352
353inline HepLorentzRotation HepLorentzRotation::inverse() const {
354 return HepLorentzRotation( mxx, myx, mzx, -mtx,
355 mxy, myy, mzy, -mty,
356 mxz, myz, mzz, -mtz,
357 -mxt, -myt, -mzt, mtt );
358}
359
360inline HepLorentzRotation & HepLorentzRotation::invert() {
361 return *this = inverse();
362}
363
364inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt ) {
365 return HepLorentzRotation(
366 HepRep4x4(
367 lt.mxx, lt.myx, lt.mzx, -lt.mtx,
368 lt.mxy, lt.myy, lt.mzy, -lt.mty,
369 lt.mxz, lt.myz, lt.mzz, -lt.mtz,
370 -lt.mxt, -lt.myt, -lt.mzt, lt.mtt ) );
371}
372
373inline double HepLorentzRotation::getTolerance() {
374 return Hep4RotationInterface::tolerance;
375}
376inline double HepLorentzRotation::setTolerance(double tol) {
377 return Hep4RotationInterface::setTolerance(tol);
378}
379
380} // namespace CLHEP
Note: See TracBrowser for help on using the repository browser.