source: trunk/CLHEP/Vector/RotationInterfaces.h@ 10

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

first commit

File size: 10.9 KB
Line 
1// -*- C++ -*-
2// CLASSDOC OFF
3// ---------------------------------------------------------------------------
4// CLASSDOC ON
5
6#ifndef HEP_ROTATION_INTERFACES_H
7#define HEP_ROTATION_INTERFACES_H
8
9// This file is a part of the CLHEP - a Class Library for High Energy Physics.
10//
11// This contains the definition of two abstract interface classes:
12// Hep4RotationInterface
13// Hep3RotationInterface.
14// However, these are mostly for defining methods which should be present in
15// any 4- or 3-rotation class, however specialized. The actual classes do
16// not inherit from these. The virtual function overhead turns out
17// to be too steep for that to be practical.
18//
19// It may be desirable in the future to turn these classes into constraints
20// in the Stroustrup sense, so as to enforce this interface, still without
21// inheritance. However, they do contain an important static:
22// static double tolerance to set criteria for relative nearness.
23//
24// This file also defines structs
25// HepRep3x3;
26// HepRep4x4;
27// HepRep4x4Symmetric;
28// which are used by various Rotation classes.
29//
30// Hep4RotationInterface
31// contains all the methods to get attributes of either a
32// HepLorentzRotation or a HepRotation -- any information
33// that pertains to a LorentzRotation can also be defined
34// for a HepRotation.(For example, the 4x4 representation
35// would just have 0's in the space-time entries and 1 in
36// the time-time entry.)
37//
38// Hep3RotationInterface
39// inherits from Hep4RotationInterface, and adds methods
40// which are well-defined only in the case of a Rotation.
41// For example, a 3x3 representation is an attribute only
42// if the generic LorentzRotation involves no boost.
43//
44// In terms of classes in the ZOOM PhysicsVectors package,
45// Hep4RotationInterface <--> LorentzTransformationInterface
46// Hep3RotationInterface <--> RotationInterface
47//
48// Hep4RotationInterface defines the required methods for:
49// HepLorentzRotation
50// HepBoost
51// HepBoostX
52// HepBoostY
53// HepBoostZ
54//
55// Hep3RotationInterface defines the required methods for:
56// HepRotation
57// HepRotationX
58// HepRotationY
59// HepRotationZ
60//
61// .SS See Also
62// Rotation.h, LorentzRotation.h
63//
64// .SS Author
65// Mark Fischler
66//
67
68#include "CLHEP/Vector/defs.h"
69#include "CLHEP/Vector/ThreeVector.h"
70#include "CLHEP/Vector/LorentzVector.h"
71#include "CLHEP/Vector/AxisAngle.h"
72
73namespace CLHEP {
74
75struct HepRep3x3;
76struct HepRep4x4;
77struct HepRep4x4Symmetric;
78
79class HepRotation;
80class HepRotationX;
81class HepRotationY;
82class HepRotationZ;
83class HepLorentzRotation;
84class HepBoost;
85class HepBoostX;
86class HepBoostY;
87class HepBoostZ;
88
89
90
91//-******************************
92//
93// Hep4RotationInterface
94//
95//-******************************
96
97/**
98 * @author
99 * @ingroup vector
100 */
101class Hep4RotationInterface {
102
103 // All attributes of shared by HepLorentzRotation, HepBoost,
104 // HepBoostX, HepBoostY, HepBoostZ. HepRotation, HepRotationX,
105 // HepRotationY, HepRotationZ also share this attribute interface.
106
107 friend class HepRotation;
108 friend class HepRotationX;
109 friend class HepRotationY;
110 friend class HepRotationZ;
111 friend class HepLorentzRotation;
112 friend class HepBoost;
113 friend class HepBoostX;
114 friend class HepBoostY;
115 friend class HepBoostZ;
116
117public:
118
119 static double tolerance; // to determine relative nearness
120
121 // ---------- Accessors:
122
123#ifdef ONLY_IN_CONCRETE_CLASSES
124 // orthosymplectic 4-vectors:
125 HepLorentzVector col1() const;
126 HepLorentzVector col2() const;
127 HepLorentzVector col3() const;
128 HepLorentzVector col4() const;
129 HepLorentzVector row1() const;
130 HepLorentzVector row2() const;
131 HepLorentzVector row3() const;
132 HepLorentzVector row4() const;
133
134 // individual elements:
135 double xx() const ;
136 double xy() const ;
137 double xz() const ;
138 double xt() const ;
139 double yx() const ;
140 double yy() const ;
141 double yz() const ;
142 double yt() const ;
143 double zx() const ;
144 double zy() const ;
145 double zz() const ;
146 double zt() const ;
147 double tx() const ;
148 double ty() const ;
149 double tz() const ;
150 double tt() const ;
151
152 // 4x4 representation:
153//HepRep4x4 rep4x4() const; JMM Declared here but not defined anywhere!
154
155 // ---------- Operations:
156 // comparisons:
157
158 inline int compare( const Hep4RotationInterface & lt ) const;
159 // Dictionary-order comparisons, utilizing the decompose(b,r) method
160
161 // decomposition:
162
163 void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
164 // Decompose as T= R * B, where R is pure rotation, B is pure boost.
165
166 void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
167 // Decompose as T= B * R, where R is pure rotation, B is pure boost.
168
169 bool operator == (const Hep4RotationInterface & r) const;
170 bool operator != (const Hep4RotationInterface & r) const;
171
172 // relative comparison:
173
174 double norm2() const ;
175 double distance2( const Hep4RotationInterface & lt ) const ;
176 double howNear( const Hep4RotationInterface & lt ) const ;
177 bool isNear (const Hep4RotationInterface & lt,
178 double epsilon=tolerance) const ;
179
180 void rectify() ;
181 // non-const but logically const correction for accumulated roundoff errors
182
183 // ---------- Apply LorentzTransformations:
184
185 HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
186 HepLorentzVector operator()( const HepLorentzVector & w ) const ;
187 // Apply to a 4-vector
188
189 // ---------- I/O:
190
191 std::ostream & print( std::ostream & os ) const;
192
193#endif /* ONLY_IN_CONCRETE_CLASSES */
194
195 static double getTolerance();
196 static double setTolerance( double tol );
197
198 enum { ToleranceTicks = 100 };
199
200protected:
201
202 ~Hep4RotationInterface() {} // protect destructor to forbid instatiation
203
204}; // Hep4RotationInterface
205
206
207
208
209//-******************************
210//
211// Hep3RotationInterface
212//
213//-******************************
214
215/**
216 * @author
217 * @ingroup vector
218 */
219class Hep3RotationInterface : public Hep4RotationInterface {
220
221 // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
222 // beyond those available by virtue of being a Hep3RotationInterface.
223
224 friend class HepRotation;
225 friend class HepRotationX;
226 friend class HepRotationY;
227 friend class HepRotationZ;
228
229public:
230
231#ifdef ONLY_IN_CONCRETE_CLASSES
232
233 // Euler angles:
234 double getPhi () const ;
235 double getTheta() const ;
236 double getPsi () const ;
237 double phi () const ;
238 double theta() const ;
239 double psi () const ;
240 HepEulerAngles eulerAngles() const ;
241
242 // axis & angle of rotation:
243 double getDelta() const ;
244 Hep3Vector getAxis () const ;
245 double delta() const ;
246 Hep3Vector axis () const ;
247 HepAxisAngle axisAngle() const ;
248
249 // orthogonal unit-length vectors:
250 Hep3Vector rowX() const;
251 Hep3Vector rowY() const;
252 Hep3Vector rowZ() const;
253
254 Hep3Vector colX() const;
255 Hep3Vector colY() const;
256 Hep3Vector colZ() const;
257
258//HepRep3x3 rep3x3() const; JMM Declared here but not defined anywhere!
259 // 3x3 representation
260
261 // orthosymplectic 4-vectors treating this as a 4-rotation:
262 HepLorentzVector col1() const;
263 HepLorentzVector col2() const;
264 HepLorentzVector col3() const;
265 HepLorentzVector col4() const;
266 HepLorentzVector row1() const;
267 HepLorentzVector row2() const;
268 HepLorentzVector row3() const;
269 HepLorentzVector row4() const;
270
271 // individual elements treating this as a 4-rotation:
272 double xt() const;
273 double yt() const;
274 double zt() const;
275 double tx() const;
276 double ty() const;
277 double tz() const;
278 double tt() const;
279
280 // ---------- Operations in the Rotation group
281
282 HepRotation operator * ( const Hep3RotationInterface & r ) const ;
283
284 // ---------- Application
285
286 HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
287 HepLorentzVector operator()( const HepLorentzVector & w ) const ;
288 // apply to HepLorentzVector
289
290 Hep3Vector operator* ( const Hep3Vector & v ) const ;
291 Hep3Vector operator()( const Hep3Vector & v ) const ;
292 // apply to Hep3Vector
293
294 // ---------- I/O and a helper method
295
296 std::ostream & print( std::ostream & os ) const;
297
298#endif /* ONLY_IN_CONCRETE_CLASSES */
299
300private:
301
302 ~Hep3RotationInterface() {} // private destructor to forbid instatiation
303
304}; // Hep3RotationInterface
305
306
307
308//-***************************
309// 3x3 and 4x4 representations
310//-***************************
311
312struct HepRep3x3 {
313
314 // ----- Constructors:
315
316 inline HepRep3x3();
317
318 inline HepRep3x3( double xx, double xy, double xz
319 , double yx, double yy, double yz
320 , double zx, double zy, double zz
321 );
322
323 inline HepRep3x3( const double * array );
324 // construct from an array of doubles, holding the rotation matrix
325 // in ROW order (xx, xy, ...)
326
327 inline void setToIdentity();
328
329 // ----- The data members are public:
330 double xx_, xy_, xz_,
331 yx_, yy_, yz_,
332 zx_, zy_, zz_;
333
334 inline void getArray ( double * array ) const;
335 // fill array with the NINE doubles xx, xy, xz ... zz
336
337}; // HepRep3x3
338
339struct HepRep4x4 {
340
341 // ----- Constructors:
342 inline HepRep4x4();
343
344 inline HepRep4x4( double xx, double xy, double xz, double xt
345 , double yx, double yy, double yz, double yt
346 , double zx, double zy, double zz, double zt
347 , double tx, double ty, double tz, double tt
348 );
349
350 inline HepRep4x4( const HepRep4x4Symmetric & rep );
351
352 inline HepRep4x4( const double * array );
353 // construct from an array of doubles, holding the transformation matrix
354 // in ROW order xx, xy, ...
355
356 inline void setToIdentity();
357
358 // ----- The data members are public:
359 double xx_, xy_, xz_, xt_,
360 yx_, yy_, yz_, yt_,
361 zx_, zy_, zz_, zt_,
362 tx_, ty_, tz_, tt_;
363
364 inline void getArray ( double * array ) const;
365 // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
366
367 inline bool operator==(HepRep4x4 const & r) const;
368 inline bool operator!=(HepRep4x4 const & r) const;
369
370
371}; // HepRep4x4
372
373struct HepRep4x4Symmetric {
374
375 // ----- Constructors:
376
377 inline HepRep4x4Symmetric();
378
379 inline HepRep4x4Symmetric
380 ( double xx, double xy, double xz, double xt
381 , double yy, double yz, double yt
382 , double zz, double zt
383 , double tt );
384
385 inline HepRep4x4Symmetric( const double * array );
386 // construct from an array of doubles, holding the transformation matrix
387 // elements in this order: xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
388
389 inline void setToIdentity();
390
391 // ----- The data members are public:
392 double xx_, xy_, xz_, xt_,
393 yy_, yz_, yt_,
394 zz_, zt_,
395 tt_;
396
397 inline void getArray ( double * array ) const;
398 // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
399
400};
401
402} // namespace CLHEP
403
404#include "CLHEP/Vector/RotationInterfaces.icc"
405
406#ifdef ENABLE_BACKWARDS_COMPATIBILITY
407// backwards compatibility will be enabled ONLY in CLHEP 1.9
408using namespace CLHEP;
409#endif
410
411#endif // ROTATION_INTERFACES_H
Note: See TracBrowser for help on using the repository browser.