16#ifndef ROOT_Math_GenVector_Transform3D
17#define ROOT_Math_GenVector_Transform3D 1
79template <
typename T =
double>
132 template <
class ARotation,
class CoordSystem,
class Tag>
144 template <
class ARotation>
201 template<
class CoordSystem,
class Tag>
225 template <
class ARotation,
class CoordSystem,
class Tag>
247 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
260 const T cos1 = x1.
Dot(y1);
261 const T cos2 = x2.
Dot(y2);
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;
267 if (std::fabs(cos1 - cos2) > T(0.000001)) {
268 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
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);
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;
321 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
322 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
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);
341 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
354 const T cos1 = x1.
Dot(y1);
355 const T cos2 = x2.
Dot(y2);
357 const auto m1 = (abs(T(1) - cos1) <= T(0.000001) || abs(T(1) - cos2) <= T(0.000001));
359 const auto m2 = (abs(cos1 - cos2) > T(0.000001));
361 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
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);
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;
414 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
415 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
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);
421 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
434 template<
class ForeignMatrix>
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)
444 SetComponents (xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
454 template <
class ForeignMatrix>
471 for (
int i = 0; i <12; ++i) {
485 for (
int i = 0; i <12; ++i) {
498 std::copy(
fM,
fM + 12, begin);
507 template<
class ForeignMatrix>
520 template<
class ForeignMatrix>
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)
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
554 template<
class AnyRotation,
class V>
581 template <
class AnyRotation>
589 template <
class AnyRotation>
603 template <
class AnyVector>
637 template <
class CoordSystem>
645 template <
class CoordSystem>
654 template<
class CoordSystem >
661 template <
class CoordSystem>
698 template <
class CoordSystem>
709 template <
class CoordSystem>
718 template <
class CoordSystem,
class Tag1,
class Tag2>
722 p2.
SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
729 template <
class CoordSystem,
class Tag1,
class Tag2>
733 v2.SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
739 template <
class CoordSystem >
747 template <
class CoordSystem>
756 template <
typename TYPE>
769 template <
typename TYPE>
790 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
804 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
818 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
825 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
838 const auto detZmask = (det == T(0));
839 if (any_of(detZmask)) {
840 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
841 where(detZmask, det) = T(1);
854 if (any_of(detZmask)) {
855 where(detZmask, detxx) = T(0);
856 where(detZmask, detxy) = T(0);
857 where(detZmask, detxz) = T(0);
858 where(detZmask, detyx) = T(0);
859 where(detZmask, detyy) = T(0);
860 where(detZmask, detyz) = T(0);
861 where(detZmask, detzx) = T(0);
862 where(detZmask, detzy) = T(0);
863 where(detZmask, detzz) = T(0);
867 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
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]);
908 r.GetComponents(rotData, rotData + 9);
910 for (
int i = 0; i < 3; ++i)
fM[i] = rotData[i];
912 for (
int i = 0; i < 3; ++i)
fM[
kYX + i] = rotData[3 + i];
914 for (
int i = 0; i < 3; ++i)
fM[
kZX + i] = rotData[6 + i];
918 v.GetCoordinates(vecData, vecData + 3);
919 fM[
kDX] = vecData[0];
920 fM[
kDY] = vecData[1];
921 fM[
kDZ] = vecData[2];
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];
935 fM[4 * i + 3] = T(0);
983 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
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";
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
DefaultCoordinateSystemTag Default tag for identifying any coordinate system.
Class describing a generic displacement vector in 3 dimensions.
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
DisplacementVector3D Cross(const DisplacementVector3D< OtherCoords, Tag > &v) const
Return vector (cross) product of two displacement vectors, as a vector in the coordinate system of th...
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Scalar Dot(const DisplacementVector3D< OtherCoords, Tag > &v) const
Return the scalar (dot) product of two displacement vectors.
EulerAngles class describing rotation as three angles (Euler Angles).
Class describing a geometrical plane in 3 dimensions.
Vector Normal() const
Return normal vector to the plane as Cartesian DisplacementVector.
Scalar HesseDistance() const
Return the Hesse Distance (distance from the origin) of the plane or the d coefficient expressed in n...
Class describing a 3 dimensional translation.
const Vector & Vect() const
return a const reference to the underline vector representing the translation
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Class describing a generic position vector (point) in 3 dimensions.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
PositionVector3D< CoordSystem, Tag > & SetXYZ(Scalar a, Scalar b, Scalar c)
set the values of the vector from the cartesian components (x,y,z) (if the vector is held in polar or...
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Rotation class with the (3D) rotation represented by angles describing first a rotation of an angle p...
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
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.
Impl::Translation3D< double > Translation3D
Impl::Transform3D< float > Transform3DF
Impl::Plane3D< double > Plane3D
Impl::Transform3D< double > Transform3D