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>
228 template <
class ARotation,
class CoordSystem,
class Tag>
250 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
263 const T cos1 =
x1.Dot(
y1);
264 const T cos2 =
x2.Dot(
y2);
266 if (std::fabs(T(1) - cos1) <= T(0.000001) || std::fabs(T(1) - cos2) <= T(0.000001)) {
267 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
270 if (std::fabs(cos1 - cos2) > T(0.000001)) {
271 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
302 T detxx = (y1y * z1z - z1y * y1z);
303 T detxy = -(y1x * z1z - z1x * y1z);
304 T detxz = (y1x * z1y - z1x * y1y);
305 T detyx = -(x1y * z1z - z1y * x1z);
306 T detyy = (x1x * z1z - z1x * x1z);
307 T detyz = -(x1x * z1y - z1x * x1y);
308 T detzx = (x1y * y1z - y1y * x1z);
309 T detzy = -(x1x * y1z - y1x * x1z);
310 T detzz = (x1x * y1y - y1x * x1y);
312 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
313 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
314 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
315 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
316 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
317 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
318 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
319 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
320 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
324 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
325 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
327 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
328 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
344 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
357 const T cos1 =
x1.Dot(
y1);
358 const T cos2 =
x2.Dot(
y2);
360 const auto m1 = (abs(T(1) - cos1) <= T(0.000001) || abs(T(1) - cos2) <= T(0.000001));
362 const auto m2 = (abs(cos1 - cos2) > T(0.000001));
364 std::cerr <<
"Transform3D: Warning: angles between axes are not equal" << std::endl;
395 T detxx = (y1y * z1z - z1y * y1z);
396 T detxy = -(y1x * z1z - z1x * y1z);
397 T detxz = (y1x * z1y - z1x * y1y);
398 T detyx = -(x1y * z1z - z1y * x1z);
399 T detyy = (x1x * z1z - z1x * x1z);
400 T detyz = -(x1x * z1y - z1x * x1y);
401 T detzx = (x1y * y1z - y1y * x1z);
402 T detzy = -(x1x * y1z - y1x * x1z);
403 T detzz = (x1x * y1y - y1x * x1y);
405 T txx = x2x * detxx + y2x * detyx + z2x * detzx;
406 T txy = x2x * detxy + y2x * detyy + z2x * detzy;
407 T txz = x2x * detxz + y2x * detyz + z2x * detzz;
408 T tyx = x2y * detxx + y2y * detyx + z2y * detzx;
409 T tyy = x2y * detxy + y2y * detyy + z2y * detzy;
410 T tyz = x2y * detxz + y2y * detyz + z2y * detzz;
411 T tzx = x2z * detxx + y2z * detyx + z2z * detzx;
412 T tzy = x2z * detxy + y2z * detyy + z2z * detzy;
413 T tzz = x2z * detxz + y2z * detyz + z2z * detzz;
417 T dx1 = fr0.
x(), dy1 = fr0.
y(), dz1 = fr0.
z();
418 T dx2 = to0.
x(), dy2 = to0.
y(), dz2 = to0.
z();
420 SetComponents(txx, txy, txz, dx2 - txx * dx1 - txy * dy1 - txz * dz1, tyx, tyy, tyz,
421 dy2 - tyx * dx1 - tyy * dy1 - tyz * dz1, tzx, tzy, tzz, dz2 - tzx * dx1 - tzy * dy1 - tzz * dz1);
424 std::cerr <<
"Transform3D: Error : zero angle between axes" << std::endl;
437 template<
class ForeignMatrix>
445 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)
447 SetComponents (xx,
xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
457 template <
class ForeignMatrix>
474 for (
int i = 0; i <12; ++i) {
488 for (
int i = 0; i <12; ++i) {
501 std::copy(
fM,
fM + 12, begin);
510 template<
class ForeignMatrix>
523 template<
class ForeignMatrix>
535 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)
545 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
557 template<
class AnyRotation,
class V>
584 template <
class AnyRotation>
592 template <
class AnyRotation>
606 template <
class AnyVector>
640 template <
class CoordSystem>
648 template <
class CoordSystem>
657 template<
class CoordSystem >
664 template <
class CoordSystem>
701 template <
class CoordSystem>
712 template <
class CoordSystem>
721 template <
class CoordSystem,
class Tag1,
class Tag2>
725 p2.
SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
732 template <
class CoordSystem,
class Tag1,
class Tag2>
736 v2.SetXYZ( xyzNew.
X(), xyzNew.
Y(), xyzNew.
Z() );
742 template <
class CoordSystem >
750 template <
class CoordSystem>
759 template <
typename TYPE>
772 template <
typename TYPE>
793 template <typename SCALAR = T, typename std::enable_if<std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
807 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
821 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
828 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
841 const auto detZmask = (det == T(0));
842 if (any_of(detZmask)) {
843 std::cerr <<
"Transform3D::inverse error: zero determinant" << std::endl;
844 det(detZmask) = T(1);
857 if (any_of(detZmask)) {
858 detxx(detZmask) = T(0);
859 detxy(detZmask) = T(0);
860 detxz(detZmask) = T(0);
861 detyx(detZmask) = T(0);
862 detyy(detZmask) = T(0);
863 detyz(detZmask) = T(0);
864 detzx(detZmask) = T(0);
865 detzy(detZmask) = T(0);
866 detzz(detZmask) = T(0);
870 detxy *
fM[
kDX] - detyy *
fM[
kDY] + detzy *
fM[
kDZ], detxz, -detyz, detzz,
890 return (
fM[0] == rhs.
fM[0] &&
fM[1] == rhs.
fM[1] &&
fM[2] == rhs.
fM[2] &&
fM[3] == rhs.
fM[3] &&
891 fM[4] == rhs.
fM[4] &&
fM[5] == rhs.
fM[5] &&
fM[6] == rhs.
fM[6] &&
fM[7] == rhs.
fM[7] &&
892 fM[8] == rhs.
fM[8] &&
fM[9] == rhs.
fM[9] &&
fM[10] == rhs.
fM[10] &&
fM[11] == rhs.
fM[11]);
911 r.GetComponents(rotData, rotData + 9);
913 for (
int i = 0; i < 3; ++i)
fM[i] = rotData[i];
915 for (
int i = 0; i < 3; ++i)
fM[
kYX + i] = rotData[3 + i];
917 for (
int i = 0; i < 3; ++i)
fM[
kZX + i] = rotData[6 + i];
921 v.GetCoordinates(vecData, vecData + 3);
922 fM[
kDX] = vecData[0];
923 fM[
kDY] = vecData[1];
924 fM[
kDZ] = vecData[2];
934 r.GetComponents(rotData, rotData + 9);
935 for (
int i = 0; i < 3; ++i) {
936 for (
int j = 0; j < 3; ++j)
fM[4 * i + j] = rotData[3 * i + j];
938 fM[4 * i + 3] = T(0);
986 template <typename SCALAR = T, typename std::enable_if<!std::is_arithmetic<SCALAR>::value>
::type * =
nullptr>
1044 fM[
kXX] * t.
fM[kDX] + fM[
kXY] * t.
fM[kDY] + fM[
kXZ] * t.
fM[kDZ] + fM[kDX],
1049 fM[
kYX] * t.
fM[kDX] + fM[
kYY] * t.
fM[kDY] + fM[
kYZ] * t.
fM[kDZ] + fM[kDY],
1054 fM[
kZX] * t.
fM[kDX] + fM[
kZY] * t.
fM[kDY] + fM[
kZZ] * t.
fM[kDZ] + fM[kDZ]);
1305 os <<
"\n" <<
m[0] <<
" " <<
m[1] <<
" " <<
m[2] <<
" " <<
m[3];
1306 os <<
"\n" <<
m[4] <<
" " <<
m[5] <<
" " <<
m[6] <<
" " <<
m[7];
1307 os <<
"\n" <<
m[8] <<
" " <<
m[9] <<
" " <<
m[10] <<
" " <<
m[11] <<
"\n";
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
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
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...