Logo ROOT   6.08/07
Reference Guide
Translation3D.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: W. Brown, M. Fischler, L. Moneta 2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 , LCG ROOT MathLib Team *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class Translation3D
12 //
13 // Created by: Lorenzo Moneta October 21 2005
14 //
15 //
16 #ifndef ROOT_Math_GenVector_Translation3D
17 #define ROOT_Math_GenVector_Translation3D 1
18 
19 
20 #ifndef ROOT_Math_GenVector_DisplacementVector3D
22 #endif
23 
24 #ifndef ROOT_Math_GenVector_PositionVector3Dfwd
26 #endif
27 
28 #ifndef ROOT_Math_GenVector_LorentzVectorfwd
30 #endif
31 
32 #include <iostream>
33 
34 
35 
36 namespace ROOT {
37 
38 namespace Math {
39 
40 
41  class Plane3D;
42 
43 
44 //____________________________________________________________________________________________________
45 /**
46  Class describing a 3 dimensional translation. It can be combined (using the operator *)
47  with the ROOT::Math::Rotation3D classes and ROOT::Math::Transform3D to obtained combined
48  transformations and to operate on points and vectors.
49  Note that a the translation applied to a Vector object (DisplacementVector3D and LorentzVector classes)
50  performes a noop, i.e. it returns the same vector. A translation can be applied only to the Point objects
51  (PositionVector3D classes).
52 
53  @ingroup GenVector
54 
55 */
56 
58 
59 
60  public:
61 
63 
64 
65 
66 
67  /**
68  Default constructor ( zero translation )
69  */
71 
72  /**
73  Construct given a pair of pointers or iterators defining the
74  beginning and end of an array of 3 Scalars representing the z,y,z of the translation vector
75  */
76  template<class IT>
77  Translation3D(IT begin, IT end)
78  {
79  fVect.SetCoordinates(begin,end);
80  }
81 
82  /**
83  Construct from x,y,z values representing the translation
84  */
85  Translation3D(double dx, double dy, double dz) :
86  fVect( Vector(dx, dy, dz) )
87  { }
88 
89 
90  /**
91  Construct from any Displacement vector in ant tag and coordinate system
92  */
93  template<class CoordSystem, class Tag>
95  fVect(Vector(v.X(),v.Y(),v.Z()))
96  { }
97 
98 
99  /**
100  Construct transformation from one coordinate system defined one point (the origin)
101  to a new coordinate system defined by other point (origin )
102  @param p1 point defining origin of original reference system
103  @param p2 point defining origin of transformed reference system
104 
105  */
106  template<class CoordSystem, class Tag>
108  fVect(p2-p1)
109  { }
110 
111 
112  // use compiler generated copy ctor, copy assignmet and dtor
113 
114 
115  // ======== Components ==============
116 
117  /**
118  return a const reference to the underline vector representing the translation
119  */
120  const Vector & Vect() const { return fVect; }
121 
122  /**
123  Set the 3 components given an iterator to the start of
124  the desired data, and another to the end (3 past start).
125  */
126  template<class IT>
127  void SetComponents(IT begin, IT end) {
128  fVect.SetCoordinates(begin,end);
129  }
130 
131  /**
132  Get the 3 components into data specified by an iterator begin
133  and another to the end of the desired data (12 past start).
134  */
135  template<class IT>
136  void GetComponents(IT begin, IT end) const {
137  fVect.GetCoordinates(begin,end);
138  }
139 
140  /**
141  Get the 3 matrix components into data specified by an iterator begin
142  */
143  template<class IT>
144  void GetComponents(IT begin) const {
145  fVect.GetCoordinates(begin);
146  }
147 
148 
149  /**
150  Set the components from 3 scalars
151  */
152  void
153  SetComponents (double dx, double dy, double dz ) {
154  fVect.SetCoordinates(dx,dy,dz);
155  }
156 
157  /**
158  Get the components into 3 scalars
159  */
160  void
161  GetComponents (double &dx, double &dy, double &dz) const {
162  fVect.GetCoordinates(dx,dy,dz);
163  }
164 
165 
166  /**
167  Set the XYZ vector components from 3 scalars
168  */
169  void
170  SetXYZ (double dx, double dy, double dz ) {
171  fVect.SetXYZ(dx,dy,dz);
172  }
173 
174 
175  // operations on points and vectors
176 
177 
178  /**
179  Transformation operation for Position Vector in any coordinate system and default tag
180  */
181  template<class CoordSystem, class Tag >
184  tmp.SetXYZ (p.X() + fVect.X(),
185  p.Y() + fVect.Y(),
186  p.Z() + fVect.Z() ) ;
187  return tmp;
188  }
189 
190  /**
191  Transformation operation for Displacement Vector in any coordinate system and default tag
192  For the Displacement Vectors no translation apply so return the vector itself
193  */
194  template<class CoordSystem, class Tag >
196  return v;
197  }
198 
199  /**
200  Transformation operation for points between different coordinate system tags
201  */
202  template<class CoordSystem, class Tag1, class Tag2 >
205  tmp.SetXYZ( p1.X(), p1.Y(), p1.Z() );
206  p2 = operator()(tmp);
207  }
208 
209 
210  /**
211  Transformation operation for Displacement Vector of different coordinate systems
212  */
213  template<class CoordSystem, class Tag1, class Tag2 >
215  // just copy v1 in v2
216  v2.SetXYZ(v1.X(), v1.Y(), v1.Z() );
217  }
218 
219  /**
220  Transformation operation for a Lorentz Vector in any coordinate system
221  A LorentzVector contains a displacement vector so no translation applies as well
222  */
223  template <class CoordSystem >
225  return q;
226  }
227 
228  /**
229  Transformation on a 3D plane
230  */
231  Plane3D operator() (const Plane3D & plane) const;
232 
233 
234  /**
235  Transformation operation for Vectors. Apply same rules as operator()
236  depending on type of vector.
237  Will work only for DisplacementVector3D, PositionVector3D and LorentzVector
238  */
239  template<class AVector >
240  AVector operator * (const AVector & v) const {
241  return operator() (v);
242  }
243 
244 
245 
246  /**
247  multiply (combine) with another transformation in place
248  */
250  fVect+= t.Vect();
251  return *this;
252  }
253 
254  /**
255  multiply (combine) two transformations
256  */
258  return Translation3D( fVect + t.Vect() );
259  }
260 
261  /**
262  Invert the transformation in place
263  */
264  void Invert() {
265  SetComponents( -fVect.X(), -fVect.Y(),-fVect.Z() );
266  }
267 
268  /**
269  Return the inverse of the transformation.
270  */
272  return Translation3D( -fVect.X(), -fVect.Y(),-fVect.Z() );
273  }
274 
275 
276  /**
277  Equality/inequality operators
278  */
279  bool operator == (const Translation3D & rhs) const {
280  if( fVect != rhs.fVect ) return false;
281  return true;
282  }
283 
284  bool operator != (const Translation3D & rhs) const {
285  return ! operator==(rhs);
286  }
287 
288 
289 
290 private:
291 
292  Vector fVect; // internal 3D vector representing the translation
293 
294 };
295 
296 
297 
298 
299 
300 // global functions
301 
302 // TODO - I/O should be put in the manipulator form
303 
304 std::ostream & operator<< (std::ostream & os, const Translation3D & t);
305 
306 // need a function Transform = Translation * Rotation ???
307 
308  } // end namespace Math
309 
310 } // end namespace ROOT
311 
312 
313 #endif /* ROOT_Math_GenVector_Translation3D */
Class describing a geometrical plane in 3 dimensions.
Definition: Plane3D.h:47
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Definition: LorentzVector.h:54
bool operator==(const Translation3D &rhs) const
Equality/inequality operators.
bool operator!=(const Translation3D &rhs) const
DisplacementVector3D< CoordSystem, Tag > & SetCoordinates(const Scalar src[])
Set internal data based on a C-style array of 3 Scalar numbers.
DisplacementVector3D< CoordSystem, Tag > & SetXYZ(Scalar a, Scalar b, Scalar c)
set the values of the vector from the cartesian components (x,y,z) (if the vector is held in polar or...
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
Translation3D()
Default constructor ( zero translation )
Definition: Translation3D.h:70
Translation3D(const DisplacementVector3D< CoordSystem, Tag > &v)
Construct from any Displacement vector in ant tag and coordinate system.
Definition: Translation3D.h:94
void GetComponents(IT begin, IT end) const
Get the 3 components into data specified by an iterator begin and another to the end of the desired d...
Class describing a generic position vector (point) in 3 dimensions.
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > Vector
Definition: Translation3D.h:62
void GetComponents(double &dx, double &dy, double &dz) const
Get the components into 3 scalars.
Translation3D(const PositionVector3D< CoordSystem, Tag > &p1, const PositionVector3D< CoordSystem, Tag > &p2)
Construct transformation from one coordinate system defined one point (the origin) to a new coordinat...
void Invert()
Invert the transformation in place.
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
Translation3D(IT begin, IT end)
Construct given a pair of pointers or iterators defining the beginning and end of an array of 3 Scala...
Definition: Translation3D.h:77
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
static double p2(double t, double a, double b, double c)
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Class describing a generic displacement vector in 3 dimensions.
const Vector & Vect() const
return a const reference to the underline vector representing the translation
SVector< double, 2 > v
Definition: Dict.h:5
void Transform(const DisplacementVector3D< CoordSystem, Tag1 > &v1, DisplacementVector3D< CoordSystem, Tag2 > &v2) const
Transformation operation for Displacement Vector of different coordinate systems. ...
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
void SetXYZ(double dx, double dy, double dz)
Set the XYZ vector components from 3 scalars.
Translation3D & operator*=(const Translation3D &t)
multiply (combine) with another transformation in place
void GetComponents(IT begin) const
Get the 3 matrix components into data specified by an iterator begin.
static double p1(double t, double a, double b)
PositionVector3D< CoordSystem, Tag > operator()(const PositionVector3D< CoordSystem, Tag > &p) const
Transformation operation for Position Vector in any coordinate system and default tag...
AVector operator*(const AVector &v) const
Transformation operation for Vectors.
void GetCoordinates(Scalar &a, Scalar &b, Scalar &c) const
get internal data into 3 Scalar numbers
Translation3D(double dx, double dy, double dz)
Construct from x,y,z values representing the translation.
Definition: Translation3D.h:85
Class describing a 3 dimensional translation.
Definition: Translation3D.h:57
void SetComponents(IT begin, IT end)
Set the 3 components given an iterator to the start of the desired data, and another to the end (3 pa...
Namespace for new Math classes and functions.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
PositionVector3D< CoordSystem, Tag > & SetXYZ(Scalar a, Scalar b, Scalar c)
set the values of the vector from the cartesian components (x,y,z) (if the vector is held in polar or...
void Transform(const PositionVector3D< CoordSystem, Tag1 > &p1, PositionVector3D< CoordSystem, Tag2 > &p2) const
Transformation operation for points between different coordinate system tags.
DefaultCoordinateSystemTag Default tag for identifying any coordinate system.
float * q
Definition: THbookFile.cxx:87
void SetComponents(double dx, double dy, double dz)
Set the components from 3 scalars.
Translation3D Inverse() const
Return the inverse of the transformation.