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);
264 if (std::fabs(T(1) - cos1) <= T(0.000001) || std::fabs(T(1) - cos2) <= T(0.000001)) {
265 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
268 if (std::fabs(cos1 - cos2) > T(0.000001)) {
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>
472 for (
int i = 0; i <12; ++i) {
486 for (
int i = 0; i <12; ++i) {
499 std::copy(
fM,
fM + 12, begin);
508 template<
class ForeignMatrix>
521 template<
class ForeignMatrix>
533 void SetComponents(T xx, T
xy, T xz, T dx, T yx, T yy, T yz, T dy, T zx, T zy, T zz, T dz)
543 void GetComponents(T &xx, T &
xy, T &xz, T &dx, T &yx, T &yy, T &yz, T &dy, T &zx, T &zy, T &zz, T &dz)
const
555 template<
class AnyRotation,
class V>
582 template <
class AnyRotation>
590 template <
class AnyRotation>
604 template <
class AnyVector>
638 template <
class CoordSystem>
646 template <
class CoordSystem>
655 template<
class CoordSystem >
662 template <
class CoordSystem>
699 template <
class CoordSystem>
710 template <
class CoordSystem>
719 template <
class CoordSystem,
class Tag1,
class Tag2>
723 p2.
SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
730 template <
class CoordSystem,
class Tag1,
class Tag2>
734 v2.SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
740 template <
class CoordSystem >
748 template <
class CoordSystem>
757 template <
typename TYPE>
770 template <
typename TYPE>
791 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
805 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
819 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
826 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
839 const auto detZmask = (det == T(0));
840 if (any_of(detZmask)) {
841 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
842 det(detZmask) = T(1);
855 if (any_of(detZmask)) {
856 detxx(detZmask) = T(0);
857 detxy(detZmask) = T(0);
858 detxz(detZmask) = T(0);
859 detyx(detZmask) = T(0);
860 detyy(detZmask) = T(0);
861 detyz(detZmask) = T(0);
862 detzx(detZmask) = T(0);
863 detzy(detZmask) = T(0);
864 detzz(detZmask) = T(0);
868 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
888 return (
fM[0] == rhs.
fM[0] &&
fM[1] == rhs.
fM[1] &&
fM[2] == rhs.
fM[2] &&
fM[3] == rhs.
fM[3] &&
889 fM[4] == rhs.
fM[4] &&
fM[5] == rhs.
fM[5] &&
fM[6] == rhs.
fM[6] &&
fM[7] == rhs.
fM[7] &&
890 fM[8] == rhs.
fM[8] &&
fM[9] == rhs.
fM[9] &&
fM[10] == rhs.
fM[10] &&
fM[11] == rhs.
fM[11]);
909 r.GetComponents(rotData, rotData + 9);
911 for (
int i = 0; i < 3; ++i)
fM[i] = rotData[i];
913 for (
int i = 0; i < 3; ++i)
fM[
kYX + i] = rotData[3 + i];
915 for (
int i = 0; i < 3; ++i)
fM[
kZX + i] = rotData[6 + i];
919 v.GetCoordinates(vecData, vecData + 3);
920 fM[
kDX] = vecData[0];
921 fM[
kDY] = vecData[1];
922 fM[
kDZ] = vecData[2];
932 r.GetComponents(rotData, rotData + 9);
933 for (
int i = 0; i < 3; ++i) {
934 for (
int j = 0; j < 3; ++j)
fM[4 * i + j] = rotData[3 * i + j];
936 fM[4 * i + 3] = T(0);
984 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
1042 fM[
kXX] * t.
fM[kDX] + fM[
kXY] * t.
fM[kDY] + fM[
kXZ] * t.
fM[kDZ] + fM[kDX],
1047 fM[
kYX] * t.
fM[kDX] + fM[
kYY] * t.
fM[kDY] + fM[
kYZ] * t.
fM[kDZ] + fM[kDY],
1052 fM[
kZX] * t.
fM[kDX] + fM[
kZY] * t.
fM[kDY] + fM[
kZZ] * t.
fM[kDZ] + fM[kDZ]);
1303 os <<
"\n" <<
m[0] <<
" " <<
m[1] <<
" " <<
m[2] <<
" " <<
m[3];
1304 os <<
"\n" <<
m[4] <<
" " <<
m[5] <<
" " <<
m[6] <<
" " <<
m[7];
1305 os <<
"\n" <<
m[8] <<
" " <<
m[9] <<
" " <<
m[10] <<
" " <<
m[11] <<
"\n";
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
static const double x2[5]
static const double x1[5]
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
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.
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.
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
Impl::Transform3D< float > Transform3DF
Impl::Transform3D< double > Transform3D
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...