Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
math/genvector/doc/externalUsage.md
Go to the documentation of this file.
1 // example on using with exteral classes (doxygen page)
2 
3 /**
4 
5  \page ExtUsagePage Examples with External Packages
6 
7 ### Connection to Linear Algebra classes
8 
9 It is possible to use the Vector and Rotation classes together with the Linear Algebra classes. It is possible to set and get the contents of any 3D or 4D Vector from a Linear Agebra Vector class which implements an iterator or something which behaves like an iterator. For example a pointer to a C array (double *) behaves like an iterator. It is then assumed that the coordinates, like (x,y,z) will be stored contiguosly.
10 
11 <pre>TVectorD r2(N) // %ROOT Linear Algebra Vector containing many vectors
12 XYZVector v2;
13 v2.SetCoordinates(&r2[INDEX],&r2[index]+3); // construct vector from x=r[INDEX], y=r[INDEX+1], z=r[INDEX+2]
14 </pre>
15 
16 To fill a Linear Algebra Vector from a 3D or 4D Vector, with GetCoordinates() one can get the internal coordinate data.
17 
18 <pre>HepVector c(3); // CLHEP Linear algebra vector
19 v2.GetCoordinates(&c[0],&c[index]+3 ) // fill HepVector c with c[0] = x, c[1] = y , c[2] = z
20 </pre>
21 
22 Or using TVectorD
23 
24 <pre>double * data[3];
25 v2.GetCoordinates(data,data+3);
26 TVectorD r1(3,data); // create a new Linear Algebra vector copying the data
27 </pre>
28 
29 In the case of transformations, constructor and method to set/get components exist with Linear Algebra matrices. The requisite is that the matrix data are stored, for example in the cse of a LorentzRotation, from (0,0) thru (3,3)
30 
31 <pre>TMatrixD(4,4) m;
32 LorentzRotation r(m) // create LorentzRotation from matrix m
33 r.GetComponents(m) // fill matrix m with LorentzRotation components
34 </pre>
35 
36 ### Connection to Other Vector classes
37 
38 The 3D and 4D vectors of the GenVector package can be constructed and assigned from any Vector, which satisfies the following requisites:
39 
40 * for 3D Vectors and Points must implement the x(), y() ans z() methods
41 * for LorentzVectors must implement the x(), y(), z() and t() methods.
42 
43 <pre>CLHEP::Hep3Vector hv;
44 XYZVector v1(hv); // create 3D Vector from CLHEP 3D Vector
45 
46 HepGeom::Point3D <double>hp;
47 XYZPoint p1(hp); // create a 3D Point from CLHEP geom Point
48 
49 CLHEP::HepLorentzVector hq;
50 XYZTVector q(hq); // create a LorentzVector from CLHEP L.V.</double> </pre>
51 
52 */