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