ROOT   Reference Guide
Transform3D.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 Transform3D
12//
13// Created by: Lorenzo Moneta October 21 2005
14//
15//
16#ifndef ROOT_Math_GenVector_Transform3D
17#define ROOT_Math_GenVector_Transform3D 1
18
19
20
22
24
26
28
29
37
38#include <iostream>
39#include <type_traits>
40#include <cmath>
41
42//#include "Math/Vector3Dfwd.h"
43
44
45
46namespace ROOT {
47
48namespace Math {
49
50namespace Impl {
51
52//_________________________________________________________________________________________
53/**
54 Basic 3D Transformation class describing a rotation and then a translation
55 The internal data are a 3D rotation data (represented as a 3x3 matrix) and a 3D vector data.
56 They are represented and held in this class like a 3x4 matrix (a simple array of 12 numbers).
57
58 The class can be constructed from any 3D rotation object
59 (ROOT::Math::Rotation3D, ROOT::Math::AxisAngle, ROOT::Math::Quaternion, etc...) and/or
60 a 3D Vector (ROOT::Math::DislacementVector3D or via ROOT::Math::Translation ) representing a Translation.
61 The Transformation is defined by applying first the rotation and then the translation.
62 A transformation defined by applying first a translation and then a rotation is equivalent to the
63 transformation obtained applying first the rotation and then a translation equivalent to the rotated vector.
64 The operator * can be used to obtain directly such transformations, in addition to combine various
65 transformations.
66 Keep in mind that the operator * (like in the case of rotations ) is not commutative.
67 The operator * is used (in addition to operator() ) to apply a transformations on the vector
68 (DisplacementVector3D and LorentzVector classes) and point (PositionVector3D) classes.
69 In the case of Vector objects the transformation only rotates them and does not translate them.
70 Only Point objects are able to be both rotated and translated.
71
72
73 @ingroup GenVector
74
75*/
76
77template <typename T = double>
79
80public:
81 typedef T Scalar;
82
85
87 kXX = 0, kXY = 1, kXZ = 2, kDX = 3,
88 kYX = 4, kYY = 5, kYZ = 6, kDY = 7,
89 kZX = 8, kZY = 9, kZZ =10, kDZ = 11
90 };
91
92
93
94 /**
95 Default constructor (identy rotation) + zero translation
96 */
98 {
100 }
101
102 /**
103 Construct given a pair of pointers or iterators defining the
104 beginning and end of an array of 12 Scalars
105 */
106 template<class IT>
107 Transform3D(IT begin, IT end)
108 {
109 SetComponents(begin,end);
110 }
111
112 /**
113 Construct from a rotation and then a translation described by a Vector
114 */
115 Transform3D( const Rotation3D & r, const Vector & v)
116 {
117 AssignFrom( r, v );
118 }
119 /**
120 Construct from a rotation and then a translation described by a Translation3D class
121 */
123
124 /**
125 Construct from a rotation (any rotation object) and then a translation
126 (represented by any DisplacementVector)
127 The requirements on the rotation and vector objects are that they can be transformed in a
128 Rotation3D class and in a Cartesian3D Vector
129 */
130 template <class ARotation, class CoordSystem, class Tag>
132 {
133 AssignFrom( Rotation3D(r), Vector (v.X(),v.Y(),v.Z()) );
134 }
135
136 /**
137 Construct from a rotation (any rotation object) and then a translation
138 represented by a Translation3D class
139 The requirements on the rotation is that it can be transformed in a
140 Rotation3D class
141 */
142 template <class ARotation>
143 Transform3D(const ARotation &r, const Translation3D<T> &t)
144 {
145 AssignFrom( Rotation3D(r), t.Vect() );
146 }
147
148
149#ifdef OLD_VERSION
150 /**
151 Construct from a translation and then a rotation (inverse assignment)
152 */
153 Transform3D( const Vector & v, const Rotation3D & r)
154 {
155 // is equivalent from having first the rotation and then the translation vector rotated
156 AssignFrom( r, r(v) );
157 }
158#endif
159
160 /**
161 Construct from a 3D Rotation only with zero translation
162 */
163 explicit Transform3D( const Rotation3D & r) {
164 AssignFrom(r);
165 }
166
167 // convenience methods for constructing a Transform3D from all the 3D rotations classes
168 // (cannot use templates for conflict with LA)
169
170 explicit Transform3D( const AxisAngle & r) {
172 }
173 explicit Transform3D( const EulerAngles & r) {
175 }
176 explicit Transform3D( const Quaternion & r) {
178 }
179 explicit Transform3D( const RotationZYX & r) {
181 }
182
183 // Constructors from axial rotations
184 // TO DO: implement direct methods for axial rotations without going through Rotation3D
185 explicit Transform3D( const RotationX & r) {
187 }
188 explicit Transform3D( const RotationY & r) {
190 }
191 explicit Transform3D( const RotationZ & r) {
193 }
194
195 /**
196 Construct from a translation only, represented by any DisplacementVector3D
197 and with an identity rotation
198 */
199 template<class CoordSystem, class Tag>
201 AssignFrom(Vector(v.X(),v.Y(),v.Z()));
202 }
203 /**
204 Construct from a translation only, represented by a Cartesian 3D Vector,
205 and with an identity rotation
206 */
207 explicit Transform3D( const Vector & v) {
208 AssignFrom(v);
209 }
210 /**
211 Construct from a translation only, represented by a Translation3D class
212 and with an identity rotation
213 */
214 explicit Transform3D(const Translation3D<T> &t) { AssignFrom(t.Vect()); }
215
216 //#if !defined(__MAKECINT__) && !defined(G__DICTIONARY) // this is ambigous with double * , double *
217
218
219#ifdef OLD_VERSION
220 /**
221 Construct from a translation (using any type of DisplacementVector )
222 and then a rotation (any rotation object).
223 Requirement on the rotation and vector objects are that they can be transformed in a
224 Rotation3D class and in a Vector
225 */
226 template <class ARotation, class CoordSystem, class Tag>
227 Transform3D(const DisplacementVector3D<CoordSystem,Tag> & v , const ARotation & r)
228 {
229 // is equivalent from having first the rotation and then the translation vector rotated
230 Rotation3D r3d(r);
231 AssignFrom( r3d, r3d( Vector(v.X(),v.Y(),v.Z()) ) );
232 }
233#endif
234
235public:
236 /**
237 Construct transformation from one coordinate system defined by three
238 points (origin + two axis) to
239 a new coordinate system defined by other three points (origin + axis)
240 Scalar version.
241 @param fr0 point defining origin of original reference system
242 @param fr1 point defining first axis of original reference system
243 @param fr2 point defining second axis of original reference system
244 @param to0 point defining origin of transformed reference system
245 @param to1 point defining first axis transformed reference system
246 @param to2 point defining second axis transformed reference system
247 */
248 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>::type * = nullptr>
249 Transform3D(const Point &fr0, const Point &fr1, const Point &fr2, const Point &to0, const Point &to1,
250 const Point &to2)
251 {
252 // takes impl. from CLHEP ( E.Chernyaev). To be checked
253
254 Vector x1 = (fr1 - fr0).Unit();
255 Vector y1 = (fr2 - fr0).Unit();
256 Vector x2 = (to1 - to0).Unit();
257 Vector y2 = (to2 - to0).Unit();
258
259 // C H E C K A N G L E S
260
261 const T cos1 = x1.Dot(y1);
262 const T cos2 = x2.Dot(y2);
263
264 if (std::fabs(T(1) - cos1) <= T(0.000001) || std::fabs(T(1) - cos2) <= T(0.000001)) {
265 std::cerr << "Transform3D: Error : zero angle between axes" << std::endl;
266 SetIdentity();
267 } else {
268 if (std::fabs(cos1 - cos2) > T(0.000001)) {
269 std::cerr << "Transform3D: Warning: angles between axes are not equal" << std::endl;
270 }
271
272 // F I N D R O T A T I O N M A T R I X
273
274 Vector z1 = (x1.Cross(y1)).Unit();
275 y1 = z1.Cross(x1);
276
277 Vector z2 = (x2.Cross(y2)).Unit();
278 y2 = z2.Cross(x2);
279
280 T x1x = x1.x();
281 T x1y = x1.y();
282 T x1z = x1.z();
283 T y1x = y1.x();
284 T y1y = y1.y();
285 T y1z = y1.z();
286 T z1x = z1.x();
287 T z1y = z1.y();
288 T z1z = z1.z();
289
290 T x2x = x2.x();
291 T x2y = x2.y();
292 T x2z = x2.z();
293 T y2x = y2.x();
294 T y2y = y2.y();
295 T y2z = y2.z();
296 T z2x = z2.x();
297 T z2y = z2.y();
298 T z2z = z2.z();
299
300 T detxx = (y1y * z1z - z1y * y1z);
301 T detxy = -(y1x * z1z - z1x * y1z);
302 T detxz = (y1x * z1y - z1x * y1y);
303 T detyx = -(x1y * z1z - z1y * x1z);
304 T detyy = (x1x * z1z - z1x * x1z);
305 T detyz = -(x1x * z1y - z1x * x1y);
306 T detzx = (x1y * y1z - y1y * x1z);
307 T detzy = -(x1x * y1z - y1x * x1z);
308 T detzz = (x1x * y1y - y1x * x1y);
309
310 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
311 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
312 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
313 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
314 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
315 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
316 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
317 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
318 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
319
320 // S E T T R A N S F O R M A T I O N
321
322 T dx1 = fr0.x(), dy1 = fr0.y(), dz1 = fr0.z();
323 T dx2 = to0.x(), dy2 = to0.y(), dz2 = to0.z();
324
325 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
326 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
327 }
328 }
329
330 /**
331 Construct transformation from one coordinate system defined by three
332 points (origin + two axis) to
333 a new coordinate system defined by other three points (origin + axis)
334 Vectorised version.
335 @param fr0 point defining origin of original reference system
336 @param fr1 point defining first axis of original reference system
337 @param fr2 point defining second axis of original reference system
338 @param to0 point defining origin of transformed reference system
339 @param to1 point defining first axis transformed reference system
340 @param to2 point defining second axis transformed reference system
341 */
342 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>::type * = nullptr>
343 Transform3D(const Point &fr0, const Point &fr1, const Point &fr2, const Point &to0, const Point &to1,
344 const Point &to2)
345 {
346 // takes impl. from CLHEP ( E.Chernyaev). To be checked
347
348 Vector x1 = (fr1 - fr0).Unit();
349 Vector y1 = (fr2 - fr0).Unit();
350 Vector x2 = (to1 - to0).Unit();
351 Vector y2 = (to2 - to0).Unit();
352
353 // C H E C K A N G L E S
354
355 const T cos1 = x1.Dot(y1);
356 const T cos2 = x2.Dot(y2);
357
358 const auto m1 = (abs(T(1) - cos1) <= T(0.000001) || abs(T(1) - cos2) <= T(0.000001));
359
360 const auto m2 = (abs(cos1 - cos2) > T(0.000001));
361 if (any_of(m2)) {
362 std::cerr << "Transform3D: Warning: angles between axes are not equal" << std::endl;
363 }
364
365 // F I N D R O T A T I O N M A T R I X
366
367 Vector z1 = (x1.Cross(y1)).Unit();
368 y1 = z1.Cross(x1);
369
370 Vector z2 = (x2.Cross(y2)).Unit();
371 y2 = z2.Cross(x2);
372
373 T x1x = x1.x();
374 T x1y = x1.y();
375 T x1z = x1.z();
376 T y1x = y1.x();
377 T y1y = y1.y();
378 T y1z = y1.z();
379 T z1x = z1.x();
380 T z1y = z1.y();
381 T z1z = z1.z();
382
383 T x2x = x2.x();
384 T x2y = x2.y();
385 T x2z = x2.z();
386 T y2x = y2.x();
387 T y2y = y2.y();
388 T y2z = y2.z();
389 T z2x = z2.x();
390 T z2y = z2.y();
391 T z2z = z2.z();
392
393 T detxx = (y1y * z1z - z1y * y1z);
394 T detxy = -(y1x * z1z - z1x * y1z);
395 T detxz = (y1x * z1y - z1x * y1y);
396 T detyx = -(x1y * z1z - z1y * x1z);
397 T detyy = (x1x * z1z - z1x * x1z);
398 T detyz = -(x1x * z1y - z1x * x1y);
399 T detzx = (x1y * y1z - y1y * x1z);
400 T detzy = -(x1x * y1z - y1x * x1z);
401 T detzz = (x1x * y1y - y1x * x1y);
402
403 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
404 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
405 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
406 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
407 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
408 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
409 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
410 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
411 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
412
413 // S E T T R A N S F O R M A T I O N
414
415 T dx1 = fr0.x(), dy1 = fr0.y(), dz1 = fr0.z();
416 T dx2 = to0.x(), dy2 = to0.y(), dz2 = to0.z();
417
418 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
419 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
420
421 if (any_of(m1)) {
422 std::cerr << "Transform3D: Error : zero angle between axes" << std::endl;
423 SetIdentity(m1);
424 }
425 }
426
427 // use compiler generated copy ctor, copy assignmet and dtor
428
429 /**
430 Construct from a linear algebra matrix of size at least 3x4,
431 which must support operator()(i,j) to obtain elements (0,0) thru (2,3).
432 The 3x3 sub-block is assumed to be the rotation part and the translations vector
433 are described by the 4-th column
434 */
435 template<class ForeignMatrix>
436 explicit Transform3D(const ForeignMatrix & m) {
438 }
439
440 /**
441 Raw constructor from 12 Scalar components
442 */
443 Transform3D(T xx, T xy, T xz, T dx, T yx, T yy, T yz, T dy, T zx, T zy, T zz, T dz)
444 {
445 SetComponents (xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
446 }
447
448
449 /**
450 Construct from a linear algebra matrix of size at least 3x4,
451 which must support operator()(i,j) to obtain elements (0,0) thru (2,3).
452 The 3x3 sub-block is assumed to be the rotation part and the translations vector
453 are described by the 4-th column
454 */
455 template <class ForeignMatrix>
456 Transform3D<T> &operator=(const ForeignMatrix &m)
457 {
459 return *this;
460 }
461
462
463 // ======== Components ==============
464
465
466 /**
467 Set the 12 matrix components given an iterator to the start of
468 the desired data, and another to the end (12 past start).
469 */
470 template<class IT>
471 void SetComponents(IT begin, IT end) {
472 for (int i = 0; i <12; ++i) {
473 fM[i] = *begin;
474 ++begin;
475 }
476 (void)end;
477 assert (end==begin);
478 }
479
480 /**
481 Get the 12 matrix components into data specified by an iterator begin
482 and another to the end of the desired data (12 past start).
483 */
484 template<class IT>
485 void GetComponents(IT begin, IT end) const {
486 for (int i = 0; i <12; ++i) {
487 *begin = fM[i];
488 ++begin;
489 }
490 (void)end;
491 assert (end==begin);
492 }
493
494 /**
495 Get the 12 matrix components into data specified by an iterator begin
496 */
497 template<class IT>
498 void GetComponents(IT begin) const {
499 std::copy(fM, fM + 12, begin);
500 }
501
502 /**
503 Set components from a linear algebra matrix of size at least 3x4,
504 which must support operator()(i,j) to obtain elements (0,0) thru (2,3).
505 The 3x3 sub-block is assumed to be the rotation part and the translations vector
506 are described by the 4-th column
507 */
508 template<class ForeignMatrix>
509 void
510 SetTransformMatrix (const ForeignMatrix & m) {
511 fM[kXX]=m(0,0); fM[kXY]=m(0,1); fM[kXZ]=m(0,2); fM[kDX]=m(0,3);
512 fM[kYX]=m(1,0); fM[kYY]=m(1,1); fM[kYZ]=m(1,2); fM[kDY]=m(1,3);
513 fM[kZX]=m(2,0); fM[kZY]=m(2,1); fM[kZZ]=m(2,2); fM[kDZ]=m(2,3);
514 }
515
516 /**
517 Get components into a linear algebra matrix of size at least 3x4,
519 (0,0) thru (2,3).
520 */
521 template<class ForeignMatrix>
522 void
523 GetTransformMatrix (ForeignMatrix & m) const {
524 m(0,0)=fM[kXX]; m(0,1)=fM[kXY]; m(0,2)=fM[kXZ]; m(0,3)=fM[kDX];
525 m(1,0)=fM[kYX]; m(1,1)=fM[kYY]; m(1,2)=fM[kYZ]; m(1,3)=fM[kDY];
526 m(2,0)=fM[kZX]; m(2,1)=fM[kZY]; m(2,2)=fM[kZZ]; m(2,3)=fM[kDZ];
527 }
528
529
530 /**
531 Set the components from 12 scalars
532 */
533 void SetComponents(T xx, T xy, T xz, T dx, T yx, T yy, T yz, T dy, T zx, T zy, T zz, T dz)
534 {
535 fM[kXX]=xx; fM[kXY]=xy; fM[kXZ]=xz; fM[kDX]=dx;
536 fM[kYX]=yx; fM[kYY]=yy; fM[kYZ]=yz; fM[kDY]=dy;
537 fM[kZX]=zx; fM[kZY]=zy; fM[kZZ]=zz; fM[kDZ]=dz;
538 }
539
540 /**
541 Get the components into 12 scalars
542 */
543 void GetComponents(T &xx, T &xy, T &xz, T &dx, T &yx, T &yy, T &yz, T &dy, T &zx, T &zy, T &zz, T &dz) const
544 {
545 xx=fM[kXX]; xy=fM[kXY]; xz=fM[kXZ]; dx=fM[kDX];
546 yx=fM[kYX]; yy=fM[kYY]; yz=fM[kYZ]; dy=fM[kDY];
547 zx=fM[kZX]; zy=fM[kZY]; zz=fM[kZZ]; dz=fM[kDZ];
548 }
549
550
551 /**
552 Get the rotation and translation vector representing the 3D transformation
553 in any rotation and any vector (the Translation class could also be used)
554 */
555 template<class AnyRotation, class V>
556 void GetDecomposition(AnyRotation &r, V &v) const {
557 GetRotation(r);
559 }
560
561
562 /**
563 Get the rotation and translation vector representing the 3D transformation
564 */
566 GetRotation(r);
568 }
569
570 /**
571 Get the 3D rotation representing the 3D transformation
572 */
574 return Rotation3D( fM[kXX], fM[kXY], fM[kXZ],
575 fM[kYX], fM[kYY], fM[kYZ],
576 fM[kZX], fM[kZY], fM[kZZ] );
577 }
578
579 /**
580 Get the rotation representing the 3D transformation
581 */
582 template <class AnyRotation>
583 AnyRotation Rotation() const {
584 return AnyRotation(Rotation3D(fM[kXX], fM[kXY], fM[kXZ], fM[kYX], fM[kYY], fM[kYZ], fM[kZX], fM[kZY], fM[kZZ]));
585 }
586
587 /**
588 Get the rotation (any type) representing the 3D transformation
589 */
590 template <class AnyRotation>
591 void GetRotation(AnyRotation &r) const {
592 r = Rotation();
593 }
594
595 /**
596 Get the translation representing the 3D transformation in a Cartesian vector
597 */
599
600 /**
601 Get the translation representing the 3D transformation in any vector
602 which implements the SetXYZ method
603 */
604 template <class AnyVector>
605 void GetTranslation(AnyVector &v) const {
606 v.SetXYZ(fM[kDX], fM[kDY], fM[kDZ]);
607 }
608
609
610
611 // operations on points and vectors
612
613 /**
614 Transformation operation for Position Vector in Cartesian coordinate
615 For a Position Vector first a rotation and then a translation is applied
616 */
617 Point operator() (const Point & p) const {
618 return Point ( fM[kXX]*p.X() + fM[kXY]*p.Y() + fM[kXZ]*p.Z() + fM[kDX],
619 fM[kYX]*p.X() + fM[kYY]*p.Y() + fM[kYZ]*p.Z() + fM[kDY],
620 fM[kZX]*p.X() + fM[kZY]*p.Y() + fM[kZZ]*p.Z() + fM[kDZ] );
621 }
622
623
624 /**
625 Transformation operation for Displacement Vectors in Cartesian coordinate
626 For the Displacement Vectors only the rotation applies - no translations
627 */
628 Vector operator() (const Vector & v) const {
629 return Vector( fM[kXX]*v.X() + fM[kXY]*v.Y() + fM[kXZ]*v.Z() ,
630 fM[kYX]*v.X() + fM[kYY]*v.Y() + fM[kYZ]*v.Z() ,
631 fM[kZX]*v.X() + fM[kZY]*v.Y() + fM[kZZ]*v.Z() );
632 }
633
634
635 /**
636 Transformation operation for Position Vector in any coordinate system
637 */
638 template <class CoordSystem>
640 {
641 return PositionVector3D<CoordSystem>(operator()(Point(p)));
642 }
643 /**
644 Transformation operation for Position Vector in any coordinate system
645 */
646 template <class CoordSystem>
648 {
649 return operator()(v);
650 }
651
652 /**
653 Transformation operation for Displacement Vector in any coordinate system
654 */
655 template<class CoordSystem >
657 return DisplacementVector3D<CoordSystem>(operator()(Vector(v)));
658 }
659 /**
660 Transformation operation for Displacement Vector in any coordinate system
661 */
662 template <class CoordSystem>
664 {
665 return operator()(v);
666 }
667
668 /**
669 Directly apply the inverse affine transformation on vectors.
670 Avoids having to calculate the inverse as an intermediate result.
671 This is possible since the inverse of a rotation is its transpose.
672 */
674 {
675 return Vector(fM[kXX] * v.X() + fM[kYX] * v.Y() + fM[kZX] * v.Z(),
676 fM[kXY] * v.X() + fM[kYY] * v.Y() + fM[kZY] * v.Z(),
677 fM[kXZ] * v.X() + fM[kYZ] * v.Y() + fM[kZZ] * v.Z());
678 }
679
680 /**
681 Directly apply the inverse affine transformation on points
682 (first inverse translation then inverse rotation).
683 Avoids having to calculate the inverse as an intermediate result.
684 This is possible since the inverse of a rotation is its transpose.
685 */
686 Point ApplyInverse(const Point &p) const
687 {
688 Point tmp(p.X() - fM[kDX], p.Y() - fM[kDY], p.Z() - fM[kDZ]);
689 return Point(fM[kXX] * tmp.X() + fM[kYX] * tmp.Y() + fM[kZX] * tmp.Z(),
690 fM[kXY] * tmp.X() + fM[kYY] * tmp.Y() + fM[kZY] * tmp.Z(),
691 fM[kXZ] * tmp.X() + fM[kYZ] * tmp.Y() + fM[kZZ] * tmp.Z());
692 }
693
694 /**
695 Directly apply the inverse affine transformation on an arbitrary
696 coordinate-system point.
697 Involves casting to Point(p) type.
698 */
699 template <class CoordSystem>
701 {
703 }
704
705 /**
706 Directly apply the inverse affine transformation on an arbitrary
707 coordinate-system vector.
708 Involves casting to Vector(p) type.
709 */
710 template <class CoordSystem>
712 {
714 }
715
716 /**
717 Transformation operation for points between different coordinate system tags
718 */
719 template <class CoordSystem, class Tag1, class Tag2>
721 {
722 const Point xyzNew = operator()(Point(p1.X(), p1.Y(), p1.Z()));
723 p2.SetXYZ( xyzNew.X(), xyzNew.Y(), xyzNew.Z() );
724 }
725
726
727 /**
728 Transformation operation for Displacement Vector of different coordinate systems
729 */
730 template <class CoordSystem, class Tag1, class Tag2>
732 {
733 const Vector xyzNew = operator()(Vector(v1.X(), v1.Y(), v1.Z()));
734 v2.SetXYZ( xyzNew.X(), xyzNew.Y(), xyzNew.Z() );
735 }
736
737 /**
738 Transformation operation for a Lorentz Vector in any coordinate system
739 */
740 template <class CoordSystem >
742 const Vector xyzNew = operator()(Vector(q.Vect()));
743 return LorentzVector<CoordSystem>(xyzNew.X(), xyzNew.Y(), xyzNew.Z(), q.E());
744 }
745 /**
746 Transformation operation for a Lorentz Vector in any coordinate system
747 */
748 template <class CoordSystem>
750 {
751 return operator()(q);
752 }
753
754 /**
755 Transformation on a 3D plane
756 */
757 template <typename TYPE>
759 {
760 // transformations on a 3D plane
761 const auto n = plane.Normal();
762 // take a point on the plane. Use origin projection on the plane
763 // ( -ad, -bd, -cd) if (a**2 + b**2 + c**2 ) = 1
764 const auto d = plane.HesseDistance();
765 Point p(-d * n.X(), -d * n.Y(), -d * n.Z());
766 return Plane3D<TYPE>(operator()(n), operator()(p));
767 }
768
769 /// Multiplication operator for 3D plane
770 template <typename TYPE>
772 {
773 return operator()(plane);
774 }
775
776 // skip transformation for arbitrary vectors - not really defined if point or displacement vectors
777
778 /**
779 multiply (combine) with another transformation in place
780 */
781 inline Transform3D<T> &operator*=(const Transform3D<T> &t);
782
783 /**
784 multiply (combine) two transformations
785 */
786 inline Transform3D<T> operator*(const Transform3D<T> &t) const;
787
788 /**
789 Invert the transformation in place (scalar)
790 */
791 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>::type * = nullptr>
792 void Invert()
793 {
794 //
795 // Name: Transform3D::inverse Date: 24.09.96
796 // Author: E.Chernyaev (IHEP/Protvino) Revised:
797 //
798 // Function: Find inverse affine transformation.
799
800 T detxx = fM[kYY] * fM[kZZ] - fM[kYZ] * fM[kZY];
801 T detxy = fM[kYX] * fM[kZZ] - fM[kYZ] * fM[kZX];
802 T detxz = fM[kYX] * fM[kZY] - fM[kYY] * fM[kZX];
803 T det = fM[kXX] * detxx - fM[kXY] * detxy + fM[kXZ] * detxz;
804 if (det == T(0)) {
805 std::cerr << "Transform3D::inverse error: zero determinant" << std::endl;
806 return;
807 }
808 det = T(1) / det;
809 detxx *= det;
810 detxy *= det;
811 detxz *= det;
812 T detyx = (fM[kXY] * fM[kZZ] - fM[kXZ] * fM[kZY]) * det;
813 T detyy = (fM[kXX] * fM[kZZ] - fM[kXZ] * fM[kZX]) * det;
814 T detyz = (fM[kXX] * fM[kZY] - fM[kXY] * fM[kZX]) * det;
815 T detzx = (fM[kXY] * fM[kYZ] - fM[kXZ] * fM[kYY]) * det;
816 T detzy = (fM[kXX] * fM[kYZ] - fM[kXZ] * fM[kYX]) * det;
817 T detzz = (fM[kXX] * fM[kYY] - fM[kXY] * fM[kYX]) * det;
818 SetComponents(detxx, -detyx, detzx, -detxx * fM[kDX] + detyx * fM[kDY] - detzx * fM[kDZ], -detxy, detyy, -detzy,
819 detxy * fM[kDX] - detyy * fM[kDY] + detzy * fM[kDZ], detxz, -detyz, detzz,
820 -detxz * fM[kDX] + detyz * fM[kDY] - detzz * fM[kDZ]);
821 }
822
823 /**
824 Invert the transformation in place (vectorised)
825 */
826 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>::type * = nullptr>
827 void Invert()
828 {
829 //
830 // Name: Transform3D::inverse Date: 24.09.96
831 // Author: E.Chernyaev (IHEP/Protvino) Revised:
832 //
833 // Function: Find inverse affine transformation.
834
835 T detxx = fM[kYY] * fM[kZZ] - fM[kYZ] * fM[kZY];
836 T detxy = fM[kYX] * fM[kZZ] - fM[kYZ] * fM[kZX];
837 T detxz = fM[kYX] * fM[kZY] - fM[kYY] * fM[kZX];
838 T det = fM[kXX] * detxx - fM[kXY] * detxy + fM[kXZ] * detxz;
839 const auto detZmask = (det == T(0));
841 std::cerr << "Transform3D::inverse error: zero determinant" << std::endl;
843 }
844 det = T(1) / det;
845 detxx *= det;
846 detxy *= det;
847 detxz *= det;
848 T detyx = (fM[kXY] * fM[kZZ] - fM[kXZ] * fM[kZY]) * det;
849 T detyy = (fM[kXX] * fM[kZZ] - fM[kXZ] * fM[kZX]) * det;
850 T detyz = (fM[kXX] * fM[kZY] - fM[kXY] * fM[kZX]) * det;
851 T detzx = (fM[kXY] * fM[kYZ] - fM[kXZ] * fM[kYY]) * det;
852 T detzy = (fM[kXX] * fM[kYZ] - fM[kXZ] * fM[kYX]) * det;
853 T detzz = (fM[kXX] * fM[kYY] - fM[kXY] * fM[kYX]) * det;
854 // Set det=0 cases to 0
865 }
866 // set final components
867 SetComponents(detxx, -detyx, detzx, -detxx * fM[kDX] + detyx * fM[kDY] - detzx * fM[kDZ], -detxy, detyy, -detzy,
868 detxy * fM[kDX] - detyy * fM[kDY] + detzy * fM[kDZ], detxz, -detyz, detzz,
869 -detxz * fM[kDX] + detyz * fM[kDY] - detzz * fM[kDZ]);
870 }
871
872 /**
873 Return the inverse of the transformation.
874 */
876 {
877 Transform3D<T> t(*this);
878 t.Invert();
879 return t;
880 }
881
882 /**
883 Equality operator. Check equality for each element
884 To do: use T tolerance
885 */
886 bool operator==(const Transform3D<T> &rhs) const
887 {
888 return (fM[0] == rhs.fM[0] && fM[1] == rhs.fM[1] && fM[2] == rhs.fM[2] && fM[3] == rhs.fM[3] &&
889 fM[4] == rhs.fM[4] && fM[5] == rhs.fM[5] && fM[6] == rhs.fM[6] && fM[7] == rhs.fM[7] &&
890 fM[8] == rhs.fM[8] && fM[9] == rhs.fM[9] && fM[10] == rhs.fM[10] && fM[11] == rhs.fM[11]);
891 }
892
893 /**
894 Inequality operator. Check equality for each element
895 To do: use T tolerance
896 */
897 bool operator!=(const Transform3D<T> &rhs) const { return !operator==(rhs); }
898
899protected:
900
901 /**
902 make transformation from first a rotation then a translation
903 */
904 void AssignFrom(const Rotation3D &r, const Vector &v)
905 {
906 // assignment from rotation + translation
907
908 T rotData[9];
909 r.GetComponents(rotData, rotData + 9);
910 // first raw
911 for (int i = 0; i < 3; ++i) fM[i] = rotData[i];
912 // second raw
913 for (int i = 0; i < 3; ++i) fM[kYX + i] = rotData[3 + i];
914 // third raw
915 for (int i = 0; i < 3; ++i) fM[kZX + i] = rotData[6 + i];
916
917 // translation data
918 T vecData[3];
919 v.GetCoordinates(vecData, vecData + 3);
920 fM[kDX] = vecData[0];
921 fM[kDY] = vecData[1];
922 fM[kDZ] = vecData[2];
923 }
924
925 /**
926 make transformation from only rotations (zero translation)
927 */
929 {
930 // assign from only a rotation (null translation)
931 T rotData[9];
932 r.GetComponents(rotData, rotData + 9);
933 for (int i = 0; i < 3; ++i) {
934 for (int j = 0; j < 3; ++j) fM[4 * i + j] = rotData[3 * i + j];
935 // empty vector data
936 fM[4 * i + 3] = T(0);
937 }
938 }
939
940 /**
941 make transformation from only translation (identity rotations)
942 */
943 void AssignFrom(const Vector &v)
944 {
945 // assign from a translation only (identity rotations)
946 fM[kXX] = T(1);
947 fM[kXY] = T(0);
948 fM[kXZ] = T(0);
949 fM[kDX] = v.X();
950 fM[kYX] = T(0);
951 fM[kYY] = T(1);
952 fM[kYZ] = T(0);
953 fM[kDY] = v.Y();
954 fM[kZX] = T(0);
955 fM[kZY] = T(0);
956 fM[kZZ] = T(1);
957 fM[kDZ] = v.Z();
958 }
959
960 /**
961 Set identity transformation (identity rotation , zero translation)
962 */
964 {
965 // set identity ( identity rotation and zero translation)
966 fM[kXX] = T(1);
967 fM[kXY] = T(0);
968 fM[kXZ] = T(0);
969 fM[kDX] = T(0);
970 fM[kYX] = T(0);
971 fM[kYY] = T(1);
972 fM[kYZ] = T(0);
973 fM[kDY] = T(0);
974 fM[kZX] = T(0);
975 fM[kZY] = T(0);
976 fM[kZZ] = T(1);
977 fM[kDZ] = T(0);
978 }
979
980 /**
981 Set identity transformation (identity rotation , zero translation)
982 vectorised version that sets using a mask
983 */
984 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>::type * = nullptr>
985 void SetIdentity(const typename SCALAR::mask_type m)
986 {
987 // set identity ( identity rotation and zero translation)
988 fM[kXX](m) = T(1);
989 fM[kXY](m) = T(0);
990 fM[kXZ](m) = T(0);
991 fM[kDX](m) = T(0);
992 fM[kYX](m) = T(0);
993 fM[kYY](m) = T(1);
994 fM[kYZ](m) = T(0);
995 fM[kDY](m) = T(0);
996 fM[kZX](m) = T(0);
997 fM[kZY](m) = T(0);
998 fM[kZZ](m) = T(1);
999 fM[kDZ](m) = T(0);
1000 }
1001
1002private:
1003 T fM[12]; // transformation elements (3x4 matrix)
1004};
1005
1006
1007
1008
1009// inline functions (combination of transformations)
1010
1011template <class T>
1013{
1014 // combination of transformations
1015
1016 SetComponents(fM[kXX]*t.fM[kXX]+fM[kXY]*t.fM[kYX]+fM[kXZ]*t.fM[kZX],
1017 fM[kXX]*t.fM[kXY]+fM[kXY]*t.fM[kYY]+fM[kXZ]*t.fM[kZY],
1018 fM[kXX]*t.fM[kXZ]+fM[kXY]*t.fM[kYZ]+fM[kXZ]*t.fM[kZZ],
1019 fM[kXX]*t.fM[kDX]+fM[kXY]*t.fM[kDY]+fM[kXZ]*t.fM[kDZ]+fM[kDX],
1020
1021 fM[kYX]*t.fM[kXX]+fM[kYY]*t.fM[kYX]+fM[kYZ]*t.fM[kZX],
1022 fM[kYX]*t.fM[kXY]+fM[kYY]*t.fM[kYY]+fM[kYZ]*t.fM[kZY],
1023 fM[kYX]*t.fM[kXZ]+fM[kYY]*t.fM[kYZ]+fM[kYZ]*t.fM[kZZ],
1024 fM[kYX]*t.fM[kDX]+fM[kYY]*t.fM[kDY]+fM[kYZ]*t.fM[kDZ]+fM[kDY],
1025
1026 fM[kZX]*t.fM[kXX]+fM[kZY]*t.fM[kYX]+fM[kZZ]*t.fM[kZX],
1027 fM[kZX]*t.fM[kXY]+fM[kZY]*t.fM[kYY]+fM[kZZ]*t.fM[kZY],
1028 fM[kZX]*t.fM[kXZ]+fM[kZY]*t.fM[kYZ]+fM[kZZ]*t.fM[kZZ],
1029 fM[kZX]*t.fM[kDX]+fM[kZY]*t.fM[kDY]+fM[kZZ]*t.fM[kDZ]+fM[kDZ]);
1030
1031 return *this;
1032}
1033
1034template <class T>
1036{
1037 // combination of transformations
1038
1039 return Transform3D<T>(fM[kXX] * t.fM[kXX] + fM[kXY] * t.fM[kYX] + fM[kXZ] * t.fM[kZX],
1040 fM[kXX] * t.fM[kXY] + fM[kXY] * t.fM[kYY] + fM[kXZ] * t.fM[kZY],
1041 fM[kXX] * t.fM[kXZ] + fM[kXY] * t.fM[kYZ] + fM[kXZ] * t.fM[kZZ],
1042 fM[kXX] * t.fM[kDX] + fM[kXY] * t.fM[kDY] + fM[kXZ] * t.fM[kDZ] + fM[kDX],
1043
1044 fM[kYX] * t.fM[kXX] + fM[kYY] * t.fM[kYX] + fM[kYZ] * t.fM[kZX],
1045 fM[kYX] * t.fM[kXY] + fM[kYY] * t.fM[kYY] + fM[kYZ] * t.fM[kZY],
1046 fM[kYX] * t.fM[kXZ] + fM[kYY] * t.fM[kYZ] + fM[kYZ] * t.fM[kZZ],
1047 fM[kYX] * t.fM[kDX] + fM[kYY] * t.fM[kDY] + fM[kYZ] * t.fM[kDZ] + fM[kDY],
1048
1049 fM[kZX] * t.fM[kXX] + fM[kZY] * t.fM[kYX] + fM[kZZ] * t.fM[kZX],
1050 fM[kZX] * t.fM[kXY] + fM[kZY] * t.fM[kYY] + fM[kZZ] * t.fM[kZY],
1051 fM[kZX] * t.fM[kXZ] + fM[kZY] * t.fM[kYZ] + fM[kZZ] * t.fM[kZZ],
1052 fM[kZX] * t.fM[kDX] + fM[kZY] * t.fM[kDY] + fM[kZZ] * t.fM[kDZ] + fM[kDZ]);
1053}
1054
1055
1056
1057
1058//--- global functions resulting in Transform3D -------
1059
1060
1061// ------ combination of a translation (first) and a rotation ------
1062
1063
1064/**
1065 combine a translation and a rotation to give a transform3d
1066 First the translation then the rotation
1067 */
1068template <class T>
1070{
1071 return Transform3D<T>(r, r(t.Vect()));
1072}
1073template <class T>
1075{
1076 Rotation3D r3(r);
1077 return Transform3D<T>(r3, r3(t.Vect()));
1078}
1079template <class T>
1081{
1082 Rotation3D r3(r);
1083 return Transform3D<T>(r3, r3(t.Vect()));
1084}
1085template <class T>
1087{
1088 Rotation3D r3(r);
1089 return Transform3D<T>(r3, r3(t.Vect()));
1090}
1091template <class T>
1093{
1094 Rotation3D r3(r);
1095 return Transform3D<T>(r3, r3(t.Vect()));
1096}
1097template <class T>
1099{
1100 Rotation3D r3(r);
1101 return Transform3D<T>(r3, r3(t.Vect()));
1102}
1103template <class T>
1105{
1106 Rotation3D r3(r);
1107 return Transform3D<T>(r3, r3(t.Vect()));
1108}
1109template <class T>
1111{
1112 Rotation3D r3(r);
1113 return Transform3D<T>(r3, r3(t.Vect()));
1114}
1115
1116// ------ combination of a rotation (first) and then a translation ------
1117
1118/**
1119 combine a rotation and a translation to give a transform3d
1120 First a rotation then the translation
1121 */
1122template <class T>
1124{
1125 return Transform3D<T>(r, t.Vect());
1126}
1127template <class T>
1129{
1130 return Transform3D<T>(Rotation3D(r), t.Vect());
1131}
1132template <class T>
1134{
1135 return Transform3D<T>(Rotation3D(r), t.Vect());
1136}
1137template <class T>
1139{
1140 return Transform3D<T>(Rotation3D(r), t.Vect());
1141}
1142template <class T>
1144{
1145 return Transform3D<T>(Rotation3D(r), t.Vect());
1146}
1147template <class T>
1149{
1150 return Transform3D<T>(Rotation3D(r), t.Vect());
1151}
1152template <class T>
1154{
1155 return Transform3D<T>(Rotation3D(r), t.Vect());
1156}
1157template <class T>
1159{
1160 return Transform3D<T>(Rotation3D(r), t.Vect());
1161}
1162
1163// ------ combination of a Transform3D and a pure translation------
1164
1165/**
1166 combine a transformation and a translation to give a transform3d
1167 First the translation then the transform3D
1168 */
1169template <class T>
1171{
1172 Rotation3D r = t.Rotation();
1173 return Transform3D<T>(r, r(d.Vect()) + t.Translation().Vect());
1174}
1175
1176/**
1177 combine a translation and a transformation to give a transform3d
1178 First the transformation then the translation
1179 */
1180template <class T>
1182{
1183 return Transform3D<T>(t.Rotation(), t.Translation().Vect() + d.Vect());
1184}
1185
1186// ------ combination of a Transform3D and any rotation------
1187
1188
1189/**
1190 combine a transformation and a rotation to give a transform3d
1191 First the rotation then the transform3D
1192 */
1193template <class T>
1195{
1196 return Transform3D<T>(t.Rotation() * r, t.Translation());
1197}
1198template <class T>
1200{
1201 return Transform3D<T>(t.Rotation() * r, t.Translation());
1202}
1203template <class T>
1205{
1206 return Transform3D<T>(t.Rotation() * r, t.Translation());
1207}
1208template <class T>
1210{
1211 return Transform3D<T>(t.Rotation() * r, t.Translation());
1212}
1213template <class T>
1215{
1216 return Transform3D<T>(t.Rotation() * r, t.Translation());
1217}
1218template <class T>
1220{
1221 return Transform3D<T>(t.Rotation() * r, t.Translation());
1222}
1223template <class T>
1225{
1226 return Transform3D<T>(t.Rotation() * r, t.Translation());
1227}
1228template <class T>
1230{
1231 return Transform3D<T>(t.Rotation() * r, t.Translation());
1232}
1233
1234
1235
1236/**
1237 combine a rotation and a transformation to give a transform3d
1238 First the transformation then the rotation
1239 */
1240template <class T>
1242{
1243 return Transform3D<T>(r * t.Rotation(), r * t.Translation().Vect());
1244}
1245template <class T>
1247{
1248 Rotation3D r3d(r);
1249 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1250}
1251template <class T>
1253{
1254 Rotation3D r3d(r);
1255 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1256}
1257template <class T>
1259{
1260 Rotation3D r3d(r);
1261 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1262}
1263template <class T>
1265{
1266 Rotation3D r3d(r);
1267 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1268}
1269template <class T>
1271{
1272 Rotation3D r3d(r);
1273 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1274}
1275template <class T>
1277{
1278 Rotation3D r3d(r);
1279 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1280}
1281template <class T>
1283{
1284 Rotation3D r3d(r);
1285 return Transform3D<T>(r3d * t.Rotation(), r3d * t.Translation().Vect());
1286}
1287
1288
1289//---I/O functions
1290// TODO - I/O should be put in the manipulator form
1291
1292/**
1293 print the 12 components of the Transform3D
1294 */
1295template <class T>
1296std::ostream &operator<<(std::ostream &os, const Transform3D<T> &t)
1297{
1298 // TODO - this will need changing for machine-readable issues
1299 // and even the human readable form needs formatting improvements
1300
1301 T m[12];
1302 t.GetComponents(m, m + 12);
1303 os << "\n" << m[0] << " " << m[1] << " " << m[2] << " " << m[3];
1304 os << "\n" << m[4] << " " << m[5] << " " << m[6] << " " << m[7];
1305 os << "\n" << m[8] << " " << m[9] << " " << m[10] << " " << m[11] << "\n";
1306 return os;
1307}
1308
1309} // end namespace Impl
1310
1311// typedefs for double and float versions
1314
1315} // end namespace Math
1316
1317} // end namespace ROOT
1318
1319
1320#endif /* ROOT_Math_GenVector_Transform3D */
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
static const double x2[5]
static const double x1[5]
int type
Definition: TGX11.cxx:120
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
float * q
Definition: THbookFile.cxx:87
typedef void((*Func_t)())
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Definition: AxisAngle.h:41
DefaultCoordinateSystemTag Default tag for identifying any coordinate system.
Class describing a generic displacement vector in 3 dimensions.
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
DisplacementVector3D Cross(const DisplacementVector3D< OtherCoords, Tag > &v) const
Return vector (cross) product of two displacement vectors, as a vector in the coordinate system of th...
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
EulerAngles class describing rotation as three angles (Euler Angles).
Definition: EulerAngles.h:43
Class describing a geometrical plane in 3 dimensions.
Definition: Plane3D.h:51
Vector Normal() const
Return normal vector to the plane as Cartesian DisplacementVector.
Definition: Plane3D.h:156
Scalar HesseDistance() const
Return the Hesse Distance (distance from the origin) of the plane or the d coefficient expressed in n...
Definition: Plane3D.h:162
Basic 3D Transformation class describing a rotation and then a translation The internal data are a 3D...
Definition: Transform3D.h:78
void GetDecomposition(AnyRotation &r, V &v) const
Get the rotation and translation vector representing the 3D transformation in any rotation and any ve...
Definition: Transform3D.h:556
void GetComponents(T &xx, T &xy, T &xz, T &dx, T &yx, T &yy, T &yz, T &dy, T &zx, T &zy, T &zz, T &dz) const
Get the components into 12 scalars.
Definition: Transform3D.h:543
Transform3D< T > Inverse() const
Return the inverse of the transformation.
Definition: Transform3D.h:875
void GetDecomposition(Rotation3D &r, Vector &v) const
Get the rotation and translation vector representing the 3D transformation.
Definition: Transform3D.h:565
Transform3D(const Point &fr0, const Point &fr1, const Point &fr2, const Point &to0, const Point &to1, const Point &to2)
Construct transformation from one coordinate system defined by three points (origin + two axis) to a ...
Definition: Transform3D.h:249
Transform3D(const AxisAngle &r)
Definition: Transform3D.h:170
Transform3D(const Rotation3D &r)
Construct from a 3D Rotation only with zero translation.
Definition: Transform3D.h:163
PositionVector3D< CoordSystem > operator*(const PositionVector3D< CoordSystem > &v) const
Transformation operation for Position Vector in any coordinate system.
Definition: Transform3D.h:647
void GetRotation(AnyRotation &r) const
Get the rotation (any type) representing the 3D transformation.
Definition: Transform3D.h:591
Translation3D< T > Translation() const
Get the translation representing the 3D transformation in a Cartesian vector.
Definition: Transform3D.h:598
void SetIdentity()
Set identity transformation (identity rotation , zero translation)
Definition: Transform3D.h:963
Transform3D(const Translation3D< T > &t)
Construct from a translation only, represented by a Translation3D class and with an identity rotation...
Definition: Transform3D.h:214
Plane3D< TYPE > operator*(const Plane3D< TYPE > &plane) const
Multiplication operator for 3D plane.
Definition: Transform3D.h:771
AnyRotation Rotation() const
Get the rotation representing the 3D transformation.
Definition: Transform3D.h:583
DisplacementVector3D< CoordSystem > ApplyInverse(const DisplacementVector3D< CoordSystem > &p) const
Directly apply the inverse affine transformation on an arbitrary coordinate-system vector.
Definition: Transform3D.h:711
Transform3D(T xx, T xy, T xz, T dx, T yx, T yy, T yz, T dy, T zx, T zy, T zz, T dz)
Raw constructor from 12 Scalar components.
Definition: Transform3D.h:443
Transform3D(const RotationZYX &r)
Definition: Transform3D.h:179
void AssignFrom(const Rotation3D &r)
make transformation from only rotations (zero translation)
Definition: Transform3D.h:928
PositionVector3D< CoordSystem > operator()(const PositionVector3D< CoordSystem > &p) const
Transformation operation for Position Vector in any coordinate system.
Definition: Transform3D.h:639
Vector ApplyInverse(const Vector &v) const
Directly apply the inverse affine transformation on vectors.
Definition: Transform3D.h:673
Transform3D(const RotationX &r)
Definition: Transform3D.h:185
void Transform(const DisplacementVector3D< CoordSystem, Tag1 > &v1, DisplacementVector3D< CoordSystem, Tag2 > &v2) const
Transformation operation for Displacement Vector of different coordinate systems.
Definition: Transform3D.h:731
Transform3D(IT begin, IT end)
Construct given a pair of pointers or iterators defining the beginning and end of an array of 12 Scal...
Definition: Transform3D.h:107
void Invert()
Invert the transformation in place (scalar)
Definition: Transform3D.h:792
Set identity transformation (identity rotation , zero translation) vectorised version that sets using...
Definition: Transform3D.h:985
Transform3D< T > & operator=(const ForeignMatrix &m)
Construct from a linear algebra matrix of size at least 3x4, which must support operator()(i,...
Definition: Transform3D.h:456
PositionVector3D< CoordSystem > ApplyInverse(const PositionVector3D< CoordSystem > &p) const
Directly apply the inverse affine transformation on an arbitrary coordinate-system point.
Definition: Transform3D.h:700
void GetTranslation(AnyVector &v) const
Get the translation representing the 3D transformation in any vector which implements the SetXYZ meth...
Definition: Transform3D.h:605
Transform3D(const DisplacementVector3D< CoordSystem, Tag > &v)
Construct from a translation only, represented by any DisplacementVector3D and with an identity rotat...
Definition: Transform3D.h:200
bool operator!=(const Transform3D< T > &rhs) const
Inequality operator.
Definition: Transform3D.h:897
void SetComponents(IT begin, IT end)
Set the 12 matrix components given an iterator to the start of the desired data, and another to the e...
Definition: Transform3D.h:471
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:485
Transform3D()
Default constructor (identy rotation) + zero translation.
Definition: Transform3D.h:97
Transform3D(const Rotation3D &r, const Translation3D< T > &t)
Construct from a rotation and then a translation described by a Translation3D class.
Definition: Transform3D.h:122
Rotation3D Rotation() const
Get the 3D rotation representing the 3D transformation.
Definition: Transform3D.h:573
Transform3D(const RotationY &r)
Definition: Transform3D.h:188
void GetComponents(IT begin) const
Get the 12 matrix components into data specified by an iterator begin.
Definition: Transform3D.h:498
PositionVector3D< Cartesian3D< T >, DefaultCoordinateSystemTag > Point
Definition: Transform3D.h:84
Transform3D(const ARotation &r, const Translation3D< T > &t)
Construct from a rotation (any rotation object) and then a translation represented by a Translation3D...
Definition: Transform3D.h:143
void SetComponents(T xx, T xy, T xz, T dx, T yx, T yy, T yz, T dy, T zx, T zy, T zz, T dz)
Set the components from 12 scalars.
Definition: Transform3D.h:533
DisplacementVector3D< CoordSystem > operator*(const DisplacementVector3D< CoordSystem > &v) const
Transformation operation for Displacement Vector in any coordinate system.
Definition: Transform3D.h:663
Transform3D(const Quaternion &r)
Definition: Transform3D.h:176
bool operator==(const Transform3D< T > &rhs) const
Equality operator.
Definition: Transform3D.h:886
Transform3D(const RotationZ &r)
Definition: Transform3D.h:191
Transform3D< T > & operator*=(const Transform3D< T > &t)
multiply (combine) with another transformation in place
Definition: Transform3D.h:1012
void AssignFrom(const Rotation3D &r, const Vector &v)
make transformation from first a rotation then a translation
Definition: Transform3D.h:904
Transform3D(const Rotation3D &r, const Vector &v)
Construct from a rotation and then a translation described by a Vector.
Definition: Transform3D.h:115
Transform3D(const EulerAngles &r)
Definition: Transform3D.h:173
Transform3D(const Vector &v)
Construct from a translation only, represented by a Cartesian 3D Vector, and with an identity rotatio...
Definition: Transform3D.h:207
DisplacementVector3D< Cartesian3D< T >, DefaultCoordinateSystemTag > Vector
Definition: Transform3D.h:83
LorentzVector< CoordSystem > operator*(const LorentzVector< CoordSystem > &q) const
Transformation operation for a Lorentz Vector in any coordinate system.
Definition: Transform3D.h:749
Plane3D< TYPE > operator()(const Plane3D< TYPE > &plane) const
Transformation on a 3D plane.
Definition: Transform3D.h:758
Transform3D(const ForeignMatrix &m)
Construct from a linear algebra matrix of size at least 3x4, which must support operator()(i,...
Definition: Transform3D.h:436
void SetTransformMatrix(const ForeignMatrix &m)
Set components from a linear algebra matrix of size at least 3x4, which must support operator()(i,...
Definition: Transform3D.h:510
void GetTransformMatrix(ForeignMatrix &m) const
Get components into a linear algebra matrix of size at least 3x4, which must support operator()(i,...
Definition: Transform3D.h:523
Point operator()(const Point &p) const
Transformation operation for Position Vector in Cartesian coordinate For a Position Vector first a ro...
Definition: Transform3D.h:617
void AssignFrom(const Vector &v)
make transformation from only translation (identity rotations)
Definition: Transform3D.h:943
void Transform(const PositionVector3D< CoordSystem, Tag1 > &p1, PositionVector3D< CoordSystem, Tag2 > &p2) const
Transformation operation for points between different coordinate system tags.
Definition: Transform3D.h:720
Point ApplyInverse(const Point &p) const
Directly apply the inverse affine transformation on points (first inverse translation then inverse ro...
Definition: Transform3D.h:686
Transform3D(const ARotation &r, const DisplacementVector3D< CoordSystem, Tag > &v)
Construct from a rotation (any rotation object) and then a translation (represented by any Displaceme...
Definition: Transform3D.h:131
Class describing a 3 dimensional translation.
Definition: Translation3D.h:51
const Vector & Vect() const
return a const reference to the underline vector representing the translation
Class describing a generic position vector (point) in 3 dimensions.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Scalar X() const
Cartesian X, 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...
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Definition: Quaternion.h:47
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition: Rotation3D.h:65
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Definition: RotationX.h:43
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition: RotationY.h:43
Rotation class with the (3D) rotation represented by angles describing first a rotation of an angle p...
Definition: RotationZYX.h:61
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition: RotationZ.h:43
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
Definition: Functions.h:381
const Int_t n
Definition: legend1.C:16
Namespace for new Math classes and functions.
double T(double x)
Definition: ChebyshevPol.h:34
Transform3D< T > operator*(const Rotation3D &r, const Translation3D< T > &t)
combine a translation and a rotation to give a transform3d First the translation then the rotation
Definition: Transform3D.h:1069
std::ostream & operator<<(std::ostream &os, const Plane3D< T > &p)
Stream Output and Input.
Definition: Plane3D.h:292
Impl::Transform3D< float > Transform3DF
Definition: Transform3D.h:1313
Impl::Transform3D< double > Transform3D
Definition: Transform3D.h:1312
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
static constexpr double m2
auto * m
Definition: textangle.C:8