16#ifndef ROOT_Math_GenVector_Transform3D
17#define ROOT_Math_GenVector_Transform3D 1
77template <
typename T =
double>
130 template <
class ARotation,
class CoordSystem,
class Tag>
142 template <
class ARotation>
199 template<
class CoordSystem,
class Tag>
226 template <
class ARotation,
class CoordSystem,
class Tag>
248 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
261 const T cos1 =
x1.Dot(y1);
262 const T cos2 =
x2.Dot(y2);
265 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
269 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
300 T detxx = (y1y * z1z - z1y * y1z);
301 T detxy = -(y1x * z1z - z1x * y1z);
302 T detxz = (y1x * z1y - z1x * y1y);
303 T detyx = -(x1y * z1z - z1y * x1z);
304 T detyy = (x1x * z1z - z1x * x1z);
305 T detyz = -(x1x * z1y - z1x * x1y);
306 T detzx = (x1y * y1z - y1y * x1z);
307 T detzy = -(x1x * y1z - y1x * x1z);
308 T detzz = (x1x * y1y - y1x * x1y);
310 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
311 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
312 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
313 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
314 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
315 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
316 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
317 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
318 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
322 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
323 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
325 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
326 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
342 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
355 const T cos1 =
x1.Dot(y1);
356 const T cos2 =
x2.Dot(y2);
358 const auto m1 = (abs(
T(1) - cos1) <=
T(0.000001) || abs(
T(1) - cos2) <=
T(0.000001));
360 const auto m2 = (abs(cos1 - cos2) >
T(0.000001));
362 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
393 T detxx = (y1y * z1z - z1y * y1z);
394 T detxy = -(y1x * z1z - z1x * y1z);
395 T detxz = (y1x * z1y - z1x * y1y);
396 T detyx = -(x1y * z1z - z1y * x1z);
397 T detyy = (x1x * z1z - z1x * x1z);
398 T detyz = -(x1x * z1y - z1x * x1y);
399 T detzx = (x1y * y1z - y1y * x1z);
400 T detzy = -(x1x * y1z - y1x * x1z);
401 T detzz = (x1x * y1y - y1x * x1y);
403 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
404 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
405 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
406 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
407 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
408 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
409 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
410 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
411 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
415 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
416 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
418 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
419 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
422 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
435 template<
class ForeignMatrix>
443 Transform3D(
T xx,
T xy,
T xz,
T dx,
T yx,
T yy,
T yz,
T dy,
T zx,
T zy,
T zz,
T dz)
445 SetComponents (xx,
xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
455 template <
class ForeignMatrix>
476 for (
int i = 0; i <12; ++i) {
493 for (
int i = 0; i <12; ++i) {
505 std::copy(
fM,
fM + 12, begin);
514 template<
class ForeignMatrix>
527 template<
class ForeignMatrix>
539 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)
549 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
561 template<
class AnyRotation,
class V>
588 template <
class AnyRotation>
596 template <
class AnyRotation>
610 template <
class AnyVector>
644 template <
class CoordSystem>
652 template <
class CoordSystem>
661 template<
class CoordSystem >
668 template <
class CoordSystem>
705 template <
class CoordSystem>
716 template <
class CoordSystem>
725 template <
class CoordSystem,
class Tag1,
class Tag2>
729 p2.
SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
736 template <
class CoordSystem,
class Tag1,
class Tag2>
740 v2.
SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
746 template <
class CoordSystem >
754 template <
class CoordSystem>
763 template <
typename TYPE>
776 template <
typename TYPE>
797 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
811 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
825 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
832 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
845 const auto detZmask = (det ==
T(0));
846 if (any_of(detZmask)) {
847 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
848 det(detZmask) =
T(1);
861 if (any_of(detZmask)) {
862 detxx(detZmask) =
T(0);
863 detxy(detZmask) =
T(0);
864 detxz(detZmask) =
T(0);
865 detyx(detZmask) =
T(0);
866 detyy(detZmask) =
T(0);
867 detyz(detZmask) =
T(0);
868 detzx(detZmask) =
T(0);
869 detzy(detZmask) =
T(0);
870 detzz(detZmask) =
T(0);
874 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
894 return (
fM[0] == rhs.
fM[0] &&
fM[1] == rhs.
fM[1] &&
fM[2] == rhs.
fM[2] &&
fM[3] == rhs.
fM[3] &&
895 fM[4] == rhs.
fM[4] &&
fM[5] == rhs.
fM[5] &&
fM[6] == rhs.
fM[6] &&
fM[7] == rhs.
fM[7] &&
896 fM[8] == rhs.
fM[8] &&
fM[9] == rhs.
fM[9] &&
fM[10] == rhs.
fM[10] &&
fM[11] == rhs.
fM[11]);
915 r.GetComponents(rotData, rotData + 9);
917 for (
int i = 0; i < 3; ++i)
fM[i] = rotData[i];
919 for (
int i = 0; i < 3; ++i)
fM[
kYX + i] = rotData[3 + i];
921 for (
int i = 0; i < 3; ++i)
fM[
kZX + i] = rotData[6 + i];
925 v.GetCoordinates(vecData, vecData + 3);
926 fM[
kDX] = vecData[0];
927 fM[
kDY] = vecData[1];
928 fM[
kDZ] = vecData[2];
938 r.GetComponents(rotData, rotData + 9);
939 for (
int i = 0; i < 3; ++i) {
940 for (
int j = 0; j < 3; ++j)
fM[4 * i + j] = rotData[3 * i + j];
942 fM[4 * i + 3] =
T(0);
990 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
1309 os <<
"\n" <<
m[0] <<
" " <<
m[1] <<
" " <<
m[2] <<
" " <<
m[3];
1310 os <<
"\n" <<
m[4] <<
" " <<
m[5] <<
" " <<
m[6] <<
" " <<
m[7];
1311 os <<
"\n" <<
m[8] <<
" " <<
m[9] <<
" " <<
m[10] <<
" " <<
m[11] <<
"\n";
static const double x2[5]
static const double x1[5]
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...
DisplacementVector3D< 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...
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
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 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.
Namespace for new Math classes and functions.
std::ostream & operator<<(std::ostream &os, const Plane3D< T > &p)
Stream Output and Input.
Impl::Transform3D< float > Transform3DF
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Namespace for new ROOT classes and functions.
static constexpr double m2