ROOT  6.06/09
Reference Guide
testIterator.cxx
Go to the documentation of this file.
1 
2 #include "Math/Vector3D.h"
3 #include "Math/Point3D.h"
4 #include "Math/Vector4D.h"
5 #include "Math/EulerAngles.h"
6 
7 #include "Math/Transform3D.h"
8 #include "Math/LorentzRotation.h"
9 #include "Math/Boost.h"
10 
11 #include "Math/Rotation3D.h"
12 #include "Math/RotationX.h"
13 #include "Math/RotationY.h"
14 #include "Math/RotationZ.h"
15 #include "Math/Quaternion.h"
16 #include "Math/AxisAngle.h"
17 #include "Math/EulerAngles.h"
18 
19 #include "Math/VectorUtil.h"
20 
21 #include <iostream>
22 #include <iterator>
23 #include <vector>
24 #include <list>
25 #include <set>
26 #include <algorithm>
27 
28 using namespace ROOT::Math;
29 using namespace ROOT::Math::VectorUtil;
30 
31 template <class Rot>
32 void printRot(const Rot & rot) {
33  std::cout << "rot: ( " ;
34  std::ostream_iterator<double> oi(std::cout," ");
35  rot.GetComponents(oi);
36  std::cout << ") " << std::endl;
37 }
38 template<class V>
39 void printVec(const V & v ) {
40  std::cout << "vec : ( " ;
41  std::ostream_iterator<double> oi(std::cout," ");
42  v.GetCoordinates(oi);
43  std::cout << ") " << std::endl;
44 }
45 template<class L>
46 void printList(const L & l ) {
47  std::cout << "list : ( " ;
48  std::ostream_iterator<double> oi(std::cout," ");
49  std::copy(l.begin(),l.end(),oi);
50  std::cout << ") " << std::endl;
51 }
52 
54 
55  XYZVector v(1.,2.,3);
56  printVec(v);
57  XYZPoint p(v); printVec(p);
58  XYZTVector q(1.,2,3,4); printVec(q);
59 
60  AxisAngle ar(v,4.); printRot(ar);
61  EulerAngles er(ar); printRot(er);
62  Quaternion qr(er); printRot(qr);
63  Rotation3D rr(qr) ; printRot(rr);
64 
65  Transform3D t(rr,v); printRot(t);
66 
67 
68  Boost b(0.3,0.4,0.8); printRot(b);
69  LorentzRotation lr(rr); printRot(lr);
70  LorentzRotation lr2(b); printRot(lr2);
71 
72 }
73 
74 void testListIter() {
75 
76  // test with lists
77  double d[10] = {1,2,3,4,5,6,7,8,9,10};
78  std::list<double> inputData(d,d+3);
79 
80  XYZVector v; v.SetCoordinates(inputData.begin(), inputData.end() );
81  std::list<double> data(3);
82  v.GetCoordinates(data.begin(),data.end());
83  printList(data);
84 
85  inputData = std::list<double>(d+3,d+6);
86  XYZPoint p; p.SetCoordinates(inputData.begin(),inputData.end() );
87  data.clear();
88  data = std::list<double>(3);
89  p.GetCoordinates(data.begin(), data.end() );
90  printList(data);
91 
92  inputData = std::list<double>(d+6,d+10);
93  XYZTVector q; q.SetCoordinates(inputData.begin(),inputData.end() );
94  data.clear();
95  data = std::list<double>(4);
96  q.GetCoordinates(data.begin(), data.end() );
97  printList(data);
98 
99  // test on rotations
100  inputData = std::list<double>(d,d+3);
101  EulerAngles re(inputData.begin(), inputData.end() );
102  data = std::list<double>(3);
103  re.GetComponents(data.begin(), data.end() );
104  printList(data);
105 
106  inputData = std::list<double>(d,d+4);
107  AxisAngle ra(inputData.begin(), inputData.end() );
108  data = std::list<double>(4);
109  ra.GetComponents(data.begin(), data.end() );
110  printList(data);
111 
112  inputData = std::list<double>(d,d+4);
113  Quaternion rq(inputData.begin(), inputData.end() );
114  data = std::list<double>(4);
115  rq.GetComponents(data.begin(), data.end() );
116  printList(data);
117 
118  double b[3] = {0.3,0.4,0.8};
119  inputData = std::list<double>(b,b+3);
120  Boost bst(inputData.begin(), inputData.end() );
121  data = std::list<double>(3);
122  bst.GetComponents(data.begin(), data.end() );
123  printList(data);
124 
125  Rotation3D tmp(ra);
126  inputData = std::list<double>(9);
127  tmp.GetComponents(inputData.begin()); printList(inputData);
128  Rotation3D r(inputData.begin(),inputData.end());
129  data = std::list<double>(9);
130  r.GetComponents(data.begin(), data.end() );
131  printList(data);
132 
133 
134  Transform3D ttmp(r,XYZVector(1,2,3));
135  inputData = std::list<double>(12);
136  ttmp.GetComponents(inputData.begin()); printList(inputData);
137  Transform3D t(inputData.begin(),inputData.end());
138  data = std::list<double>(12);
139  t.GetComponents(data.begin(), data.end() );
140  printList(data);
141 
142 
143  LorentzRotation ltmp(bst);
144  inputData = std::list<double>(16);
145  ltmp.GetComponents(inputData.begin()); printList(inputData);
146  LorentzRotation lr(inputData.begin(),inputData.end());
147  data = std::list<double>(16);
148  lr.GetComponents(data.begin(), data.end() );
149  printList(data);
150 
151 
152 }
153 
154 int main() {
155 
156  testOstreamIter();
157  testListIter();
158 
159 
160 }
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Definition: LorentzVector.h:54
DisplacementVector3D< CoordSystem, Tag > & SetCoordinates(const Scalar src[])
Set internal data based on a C-style array of 3 Scalar numbers.
RooArgList L(const RooAbsArg &v1)
void printRot(const Rot &rot)
Class describing a generic position vector (point) in 3 dimensions.
void GetCoordinates(Scalar &a, Scalar &b, Scalar &c) const
get internal data into 3 Scalar numbers
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition: Quaternion.h:47
int main()
void testListIter()
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Definition: AxisAngle.h:41
Lorentz boost class with the (4D) transformation represented internally by a 4x4 orthosymplectic matr...
Definition: Boost.h:46
Lorentz transformation class with the (4D) transformation represented by a 4x4 orthosymplectic matrix...
void printVec(const V &v)
void GetComponents(IT begin, IT end) const
Get the 12 matrix components into data specified by an iterator begin and another to the end of the d...
Definition: Transform3D.h:331
Global Helper functions for generic Vector classes.
Definition: VectorUtil.h:47
ROOT::R::TRInterface & r
Definition: Object.C:4
SVector< double, 2 > v
Definition: Dict.h:5
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition: Rotation3D.h:65
void GetComponents(Foreign4Vector &v1, Foreign4Vector &v2, Foreign4Vector &v3, Foreign4Vector &v4) const
Get components into four 4-vectors which will be the (orthosymplectic) columns of the rotation matrix...
Basic 3D Transformation class describing a rotation and then a translation The internal data are a 3D...
Definition: Transform3D.h:85
TLine * l
Definition: textangle.C:4
void GetComponents(ForeignVector &v1, ForeignVector &v2, ForeignVector &v3) const
Get components into three vectors which will be the (orthonormal) columns of the rotation matrix...
Definition: Rotation3D.h:249
EulerAngles class describing rotation as three angles (Euler Angles).
Definition: EulerAngles.h:43
void printList(const L &l)
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
3D Vector based on the cartesian coordinates x,y,z in double precision
Definition: Vector3Dfwd.h:34
void testOstreamIter()
float * q
Definition: THbookFile.cxx:87