![]() |
ROOT 6.12/07 Reference Guide |
Transformations classes are grouped in Rotations (in 3 dimensions), Lorentz transformations and Poincarre transformations, which are Translation/Rotation combinations. Each group has several members which may model physically equivalent trasformations but with different internal representations. All the classes are non-template and use double precision as the scalar type The following types of transformation classes are defined:
All rotations and transformations are default constructible (giving the identity transformation). All rotations are constructible taking a number of scalar argumnts matching the number (and order of components)
Rotation3D rI; // create a summy rotation (Identity matrix) RotationX rX(M_PI); // create a rotationX with an angle PI EulerAngles rE(phi, theta, psi); // create a Euler rotation with phi,theta,psi angles XYZVector u(ux,uy,uz); AxisAngle rA(u, delta); // create a rotation based on direction u with delta angle
In addition, all rotations and transformations (other than the axial rotations) and transformations are constructible from (begin,end) iterators or from pointers whicih behave like iterators.
double data[9]; Rotation3D r(data, data+9); // create a rotation from a rotation matrix std::vector <double>w(12); Transform3D t(w.begin(),w.end()); // create a Transform3D from the content of a std::vector</double>
All rotations, except the axial rotations, are constructible and assigned from any other type of rotation (including the axial):
Rotation3D r(ROOT::Math::RotationX(PI)); // create a rotation 3D from a rotation along X axis of angle PI EulerAngles r2(r); // construct an Euler Rotation from A Rotation3D AxisAngle r3; r3 = r2; // assign an Axis Rotation from an Euler Rotation;
Transform3D (rotation + translation) can be constructed from a rotation and a translation vector
Rotation3D r; XYZVector v; Transform3D t1(r,v); // construct from rotation and then translation Transform3D t2(v,r); // construct inverse from first translation then rotation Transform3D t3(r); // construct from only a rotation (zero translation) Transform3D t4(v); // construct from only translation (identity rotation)
All transformations can be applied to vector and points using the operator * or using the operator()
XYZVector v1(...); Rotation3D r(...); XYZVector v2 = r*v1; // rotate vector v1 using r v2 = r(v1) // equivalent
Transformations can be combined using the operator * . Note that the rotations are not commutative ans therefore the order is important
Rotation3D r1(...); Rotation3D r2(...); Rotation3D r3 = r2*r1; // obtain a combine rotation r3 by applying first r1 then r2
We can combine rotations of different types, like Rotation3D with any other type of rotations. The product of two different axial rotations return a Rotation3D:
RotationX rx(1.); RotationY ry(2.); Rotation3D r = ry * rx; // rotation along X and then Y axis
It is also possible to invert all the transformation or return the inverse of a transformation
Rotation3D r1(...); r1.Invert(); // invert the rotation modifying its content Rotation3D r2 =r1.Inverse(); // return the inverse in a new rotation class
We have used rotation as examples, but all these operations can be applied to all the transformation classes. Rotation3D, Transform3D and Translation3D classes can all be combined via the operator *.
Rotation3D r(AxisAngle(phi,ux,uy,uz)); // rotation of an angle phi around u. Translation3D d(dx,dy,dz); // translation of a vector d Transform3D t1 = d * r; // transformation obtained applying first the rotation Transform3D t2 = r * d; // transformation obtained applying first the translation
Common methods to all the transformations are the Get and SetComponents. They can be used to retrieve all the scalar values on which the trasformation is based. They can be used with a signature based iterators or by using any foreign matrix which implements the operator(i,j) or a different signatures depending on the transformation type.
RotationX rx; rx.SetComponents(1.) // set agle of the X rotation double d[9] = {........} Rotation3D r; r.SetComponents(d,d+9); // set 9 components of 3D rotation double d[16]; LorentzRotation lr; lr.GetComponents( d, d+16); // get 16 components of a LorentzRotation TMatrixD(3,4) m; Transform3D t; t.GetComponens(m); // fill matrix of size 3x4 with components of the transform3D t
For more detailed documentation on all methods see the reference doc for the specific transformation class.
*/