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