56 const double uZ = m[
kYX] - m[
kXY];
57 const double uY = m[
kXZ] - m[
kZX];
58 const double uX = m[
kZY] - m[
kYZ];
76 static const double pi =
M_PI;
79 const double cosdelta = (m[
kXX] + m[
kYY] + m[
kZZ] - 1.0) / 2.0;
82 }
else if (cosdelta < -1.0) {
96 static const double pi =
M_PI;
118 double phi, theta, psi;
119 double psiPlusPhi, psiMinusPhi;
120 static const double pi =
M_PI;
121 static const double pi_2 =
M_PI_2;
124 (r[
kZZ] > 0.0) ? 0 :
pi;
126 double cosTheta = r[
kZZ];
127 if (cosTheta > 1) cosTheta = 1;
128 if (cosTheta < -1) cosTheta = -1;
137 }
else if (cosTheta >= 0) {
141 psiMinusPhi =
atan2 ( s, c );
142 }
else if (cosTheta > -1) {
146 psiPlusPhi =
atan2 ( s, c );
152 psi = .5 * (psiPlusPhi + psiMinusPhi);
153 phi = .5 * (psiPlusPhi - psiMinusPhi);
161 w[0] = r[
kXZ]; w[1] = r[
kZX]; w[2] = r[
kYZ]; w[3] = -r[
kZY];
166 for (
int i = 1; i < 4; ++i) {
205 const double d0 = m[
kXX] + m[
kYY] + m[
kZZ];
206 const double d1 = + m[
kXX] - m[
kYY] - m[
kZZ];
207 const double d2 = - m[
kXX] + m[
kYY] - m[
kZZ];
208 const double d3 = - m[
kXX] - m[
kYY] + m[
kZZ];
213 if ( d0 >= d1 && d0 >= d2 && d0 >= d3 ) {
215 const double f = .25/q0;
216 const double q1 = f*(m[
kZY]-m[
kYZ]);
217 const double q2 = f*(m[
kXZ]-m[
kZX]);
218 const double q3 = f*(m[
kYX]-m[
kXY]);
222 }
else if ( d1 >= d2 && d1 >= d3 ) {
224 const double f = .25/q1;
225 const double q0 = f*(m[
kZY]-m[
kYZ]);
226 const double q2 = f*(m[
kXY]+m[
kYX]);
227 const double q3 = f*(m[
kXZ]+m[
kZX]);
231 }
else if ( d2 >= d3 ) {
233 const double f = .25/q2;
234 const double q0 = f*(m[
kXZ]-m[
kZX]);
235 const double q1 = f*(m[
kXY]+m[
kYX]);
236 const double q3 = f*(m[
kYZ]+m[
kZY]);
242 const double f = .25/q3;
243 const double q0 = f*(m[
kYX]-m[
kXY]);
244 const double q1 = f*(m[
kXZ]+m[
kZX]);
245 const double q2 = f*(m[
kYZ]+m[
kZY]);
263 static const double pi_2 =
M_PI_2;
268 double phi,theta,psi = 0;
271 double sinTheta = r[
kXZ];
272 if ( sinTheta < -1.0) sinTheta = -1.0;
273 if ( sinTheta > 1.0) sinTheta = 1.0;
283 double psiPlusPhi = 0;
284 double psiMinusPhi = 0;
287 if (sinTheta > - 1.0)
292 psiMinusPhi =
atan2 ( r[kZY] - r[
kYX] , r[
kYY] + r[kZX] );
294 psi = .5 * (psiPlusPhi + psiMinusPhi);
295 phi = .5 * (psiPlusPhi - psiMinusPhi);
313 w[0] = -r[
kYZ]; w[1] = -r[
kXY]; w[2] = r[
kZZ]; w[3] = r[
kXX];
318 for (
int i = 1; i < 4; ++i) {
359 const double oneMinusCosDelta = 1.0 - cosDelta;
362 const double uX = u.
X();
363 const double uY = u.
Y();
364 const double uZ = u.
Z();
368 m[
kXX] = oneMinusCosDelta * uX * uX + cosDelta;
369 m[
kXY] = oneMinusCosDelta * uX * uY - sinDelta * uZ;
370 m[
kXZ] = oneMinusCosDelta * uX * uZ + sinDelta * uY;
372 m[
kYX] = oneMinusCosDelta * uY * uX + sinDelta * uZ;
373 m[
kYY] = oneMinusCosDelta * uY * uY + cosDelta;
374 m[
kYZ] = oneMinusCosDelta * uY * uZ - sinDelta * uX;
376 m[
kZX] = oneMinusCosDelta * uZ * uX - sinDelta * uY;
377 m[
kZY] = oneMinusCosDelta * uZ * uY + sinDelta * uX;
378 m[
kZZ] = oneMinusCosDelta * uZ * uZ + cosDelta;
432 ( cPsi*cPhi-sPsi*cTheta*sPhi, cPsi*sPhi+sPsi*cTheta*cPhi, sPsi*sTheta
433 , -sPsi*cPhi-cPsi*cTheta*sPhi, -sPsi*sPhi+cPsi*cTheta*cPhi, cPsi*sTheta
434 , sTheta*sPhi, -sTheta*cPhi, cTheta
452 const Scalar plus = (from.
Phi()+from.
Psi())/2;
453 const Scalar minus = (from.
Phi()-from.
Psi())/2;
454 const Scalar sPlus =
std::sin( plus );
455 const Scalar cPlus =
std::cos( plus );
456 const Scalar sMinus =
std::sin( minus );
457 const Scalar cMinus =
std::cos( minus );
461 to.
SetComponents ( cTheta*cPlus, -sTheta*cMinus, -sTheta*sMinus, -cTheta*sPlus );
482 const double q0 = from.
U();
483 const double q1 = from.
I();
484 const double q2 = from.
J();
485 const double q3 = from.
K();
486 const double q00 = q0*q0;
487 const double q01 = q0*q1;
488 const double q02 = q0*q2;
489 const double q03 = q0*q3;
490 const double q11 = q1*q1;
491 const double q12 = q1*q2;
492 const double q13 = q1*q3;
493 const double q22 = q2*q2;
494 const double q23 = q2*q3;
495 const double q33 = q3*q3;
498 q00+q11-q22-q33 , 2*(q12-q03) , 2*(q02+q13),
499 2*(q12+q03) , q00-q11+q22-q33 , 2*(q23-q01),
500 2*(q13-q02) , 2*(q23+q01) , q00-q11-q22+q33 );
511 const double angle = 2.0 *
std::acos ( from.
U() );
513 axis (from.
I(), from.
J(), from.
K());
516 if ( u < -1 ) u = -1;
517 const double angle = 2.0 *
std::acos ( -from.
U() );
519 axis (-from.
I(), -from.
J(), -from.
K());
549 double phi,theta,psi = 0;
580 double phi,theta,psi = 0;
589 to.
SetComponents( cphi2 * cpsi2 * ctheta2 - sphi2 * spsi2 * stheta2,
590 sphi2 * cpsi2 * stheta2 + cphi2 * spsi2 * ctheta2,
591 cphi2 * cpsi2 * stheta2 - sphi2 * spsi2 * ctheta2,
592 sphi2 * cpsi2 * ctheta2 + cphi2 * spsi2 * stheta2
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Scalar Angle() const
Angle of rotation.
DisplacementVector3D< CoordSystem, Tag > & SetCoordinates(const Scalar src[])
Set internal data based on a C-style array of 3 Scalar numbers.
static constexpr double pi
Namespace for new ROOT classes and functions.
void SetComponents(IT begin, IT end)
Set the three Euler angles given a pair of pointers or iterators defining the beginning and end of an...
void GetComponents(ForeignVector &v1, ForeignVector &v2, ForeignVector &v3) const
Get components into three vectors which will be the (orthonormal) columns of the rotation matrix...
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Rotation class with the (3D) rotation represented by angles describing first a rotation of an angle p...
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Scalar Phi() const
Return Phi Euler angle.
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
Scalar Psi() const
Return Psi Euler angle.
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Scalar U() const
Access to the four quaternion components: U() is the coefficient of the identity Pauli matrix...
void SetComponents(IT begin, IT end)
Set the axis and then the angle given a pair of pointers or iterators defining the beginning and end ...
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
Scalar Theta() const
Return Theta Euler angle.
AxisVector Axis() const
accesss to rotation axis
void Rectify()
Re-adjust components to eliminate small deviations from the axis being a unit vector and angles out o...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Scalar Angle() const
Angle of rotation.
Scalar Angle() const
access to rotation angle
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
static void correctByPi(double &psi, double &phi)
void GetComponents(IT begin, IT end) const
Get the axis and then the angle into data specified by an iterator begin and another to the end of th...
void convert(R1 const &, R2 const)
double atan2(double, double)
EulerAngles class describing rotation as three angles (Euler Angles).
static constexpr double s
Namespace for new Math classes and functions.
void SetComponents(const ForeignVector &v1, const ForeignVector &v2, const ForeignVector &v3)
Set components from three orthonormal vectors (which must have methods x(), y() and z()) which will b...
void Rectify()
Re-adjust components to eliminate small deviations from |Q| = 1 orthonormality.
Scalar Angle() const
Angle of rotation.
void SetComponents(IT begin, IT end)
Set the three Euler angles given a pair of pointers or iterators defining the beginning and end of an...
Rotation3D::Scalar Scalar
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
void SetComponents(IT begin, IT end)
Set the four components given an iterator to the start of the desired data, and another to the end (4...