Hall-D Software  alpha
DCoordinateSystem.h
Go to the documentation of this file.
1 // \$Id\$
2 //
3 // File: DCoordinateSystem.h
4 // Created: Thu Nov 16 10:15:12 EST 2006
5 // Creator: davidl (on Darwin swire-b241.jlab.org 8.8.0 powerpc)
6 //
7
8 #ifndef _DCoordinateSystem_
9 #define _DCoordinateSystem_
10
11 #include <DVector3.h>
12
14  public:
16  virtual ~DCoordinateSystem(){}
17
18  DVector3 origin; //< x,y,z-coordinate of origin in lab coordinates
19  DVector3 sdir; //< direction of s-axis in lab coordinates
20  DVector3 tdir; //< direction of t-axis in lab coordinates
21  DVector3 udir; //< direction of u-axis in lab coordinates
22  double L; //< length of wire (if this represents a wire)
23
24  inline void ToLab(double &x, double &y, double &z);
25  inline void FromLab(double &x, double &y, double &z);
26  inline void ToLab(DVector3 &pos);
27  inline void FromLab(DVector3 &pos);
28 };
29
30 //---------------------------------
31 // ToLab
32 //---------------------------------
33 inline void DCoordinateSystem::ToLab(double &x, double &y, double &z)
34 {
35  /// Transform the given vector from this coordinate
36  /// system into the lab coordinate system.
37  DVector3 pos(x,y,z);
38  ToLab(pos);
39  x= pos.x();
40  y= pos.y();
41  z= pos.z();
42 }
43
44 //---------------------------------
45 // FromLab
46 //---------------------------------
47 inline void DCoordinateSystem::FromLab(double &x, double &y, double &z)
48 {
49  /// Transform the given vector from the lab coordinate
50  /// system into this coordinate system.
51  DVector3 pos(x,y,z);
52  FromLab(pos);
53  x= pos.x();
54  y= pos.y();
55  z= pos.z();
56 }
57
58 //---------------------------------
59 // ToLab
60 //---------------------------------
62 {
63  /// Transform the given vector from this coordinate
64  /// system into the lab coordinate system.
65  pos = origin + pos.x()*sdir + pos.y()*tdir + pos.z()*udir;
66 }
67
68 //---------------------------------
69 // FromLab
70 //---------------------------------
72 {
73  /// Transform the given vector from the lab coordinate
74  /// system into this coordinate system.
75  pos -= origin;
76  pos.SetXYZ(pos.Dot(sdir), pos.Dot(tdir), pos.Dot(udir));
77 }
78
79
80 #endif // _DCoordinateSystem_
81
TVector3 DVector3
Definition: DVector3.h:14
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
virtual ~DCoordinateSystem()
void ToLab(double &x, double &y, double &z)
void FromLab(double &x, double &y, double &z)