45#if __cplusplus >= 202002L
74 if (
math_fabs(uX) < 8. * std::numeric_limits<double>::epsilon() &&
75 math_fabs(uY) < 8. * std::numeric_limits<double>::epsilon() &&
76 math_fabs(uZ) < 8. * std::numeric_limits<double>::epsilon()) {
87 static const double pi =
M_PI;
90 const double cosdelta = (
m[
kXX] +
m[
kYY] +
m[
kZZ] - 1.0) / 2.0;
93 }
else if (cosdelta < -1.0) {
107 static const double pi =
M_PI;
127 double phi, theta, psi;
128 double psiPlusPhi, psiMinusPhi;
129 static const double pi =
M_PI;
130 static const double pi_2 =
M_PI_2;
134 double cosTheta =
r[
kZZ];
147 }
else if (cosTheta >= 0) {
152 }
else if (cosTheta > -1) {
162 psi = .5 * (psiPlusPhi + psiMinusPhi);
163 phi = .5 * (psiPlusPhi - psiMinusPhi);
179 for (
int i = 1; i < 4; ++i) {
189 if (w[0] > 0 && psi < 0)
191 if (w[0] < 0 && psi > 0)
195 if (w[1] > 0 && phi < 0)
197 if (w[1] < 0 && phi > 0)
234 if (d0 >= d1 && d0 >= d2 && d0 >= d3) {
235 const double q0 = .5 *
math_sqrt(1 + d0);
236 const double f = .25 / q0;
243 }
else if (d1 >= d2 && d1 >= d3) {
244 const double q1 = .5 *
math_sqrt(1 + d1);
245 const double f = .25 / q1;
252 }
else if (d2 >= d3) {
253 const double q2 = .5 *
math_sqrt(1 + d2);
254 const double f = .25 / q2;
262 const double q3 = .5 *
math_sqrt(1 + d3);
263 const double f = .25 / q3;
283 static const double pi_2 =
M_PI_2;
288 double phi, theta, psi = 0;
291 double sinTheta =
r[
kXZ];
305 double psiPlusPhi = 0;
306 double psiMinusPhi = 0;
316 psi = .5 * (psiPlusPhi + psiMinusPhi);
317 phi = .5 * (psiPlusPhi - psiMinusPhi);
343 for (
int i = 1; i < 4; ++i) {
354 if (w[0] > 0 && psi < 0)
356 if (w[0] < 0 && psi > 0)
360 if (w[1] > 0 && phi < 0)
362 if (w[1] < 0 && phi > 0)
392 const double oneMinusCosDelta = 1.0 - cosDelta;
395 const double uX = u.
X();
396 const double uY = u.
Y();
397 const double uZ = u.
Z();
401 m[
kXX] = oneMinusCosDelta * uX * uX + cosDelta;
402 m[
kXY] = oneMinusCosDelta * uX * uY - sinDelta * uZ;
403 m[
kXZ] = oneMinusCosDelta * uX * uZ + sinDelta * uY;
405 m[
kYX] = oneMinusCosDelta * uY * uX + sinDelta * uZ;
406 m[
kYY] = oneMinusCosDelta * uY * uY + cosDelta;
407 m[
kYZ] = oneMinusCosDelta * uY * uZ - sinDelta * uX;
409 m[
kZX] = oneMinusCosDelta * uZ * uX - sinDelta * uY;
410 m[
kZY] = oneMinusCosDelta * uZ * uY + sinDelta * uX;
411 m[
kZZ] = oneMinusCosDelta * uZ * uZ + cosDelta;
459 to.
SetComponents(cPsi * cPhi - sPsi * cTheta * sPhi, cPsi * sPhi + sPsi * cTheta * cPhi, sPsi * sTheta,
460 -sPsi * cPhi - cPsi * cTheta * sPhi, -sPsi * sPhi + cPsi * cTheta * cPhi, cPsi * sTheta,
461 sTheta * sPhi, -sTheta * cPhi, cTheta);
487 to.
SetComponents(cTheta * cPlus, -sTheta * cMinus, -sTheta * sMinus, -cTheta * sPlus);
507 const double q0 = from.
U();
508 const double q1 = from.
I();
509 const double q2 = from.
J();
510 const double q3 = from.
K();
511 const double q00 = q0 * q0;
512 const double q01 = q0 * q1;
513 const double q02 = q0 * q2;
514 const double q03 = q0 * q3;
515 const double q11 = q1 * q1;
516 const double q12 = q1 * q2;
517 const double q13 = q1 * q3;
518 const double q22 = q2 * q2;
519 const double q23 = q2 * q3;
520 const double q33 = q3 * q3;
522 to.
SetComponents(q00 + q11 - q22 - q33, 2 * (q12 - q03), 2 * (q02 + q13), 2 * (q12 + q03), q00 - q11 + q22 - q33,
523 2 * (q23 - q01), 2 * (q13 - q02), 2 * (q23 + q01), q00 - q11 - q22 + q33);
535 const double angle = 2.0 *
math_acos(from.
U());
541 const double angle = 2.0 *
math_acos(-from.
U());
573 double phi, theta, psi = 0;
602 double phi, theta, psi = 0;
607 double stheta2 =
math_sin(theta / 2);
608 double ctheta2 =
math_cos(theta / 2);
612 cphi2 * cpsi2 * ctheta2 - sphi2 * spsi2 * stheta2, sphi2 * cpsi2 * stheta2 + cphi2 * spsi2 * ctheta2,
613 cphi2 * cpsi2 * stheta2 - sphi2 * spsi2 * ctheta2, sphi2 * cpsi2 * ctheta2 + cphi2 * spsi2 * stheta2);
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
DisplacementVector3D< Cartesian3D< Scalar > > AxisVector
definition of vector axis
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 ...
AxisVector Axis() const
access to rotation axis
Scalar Angle() const
access to rotation angle
void Rectify()
Re-adjust components to eliminate small deviations from the axis being a unit vector and angles out o...
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.
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
DisplacementVector3D< CoordSystem, Tag > & SetCoordinates(const Scalar src[])
Set internal data based on a C-style array of 3 Scalar numbers.
EulerAngles class describing rotation as three angles (Euler Angles).
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...
Scalar Psi() const
Return Psi Euler angle.
Scalar Phi() const
Return Phi Euler angle.
Scalar Theta() const
Return Theta Euler angle.
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Scalar U() const
Access to the four quaternion components: U() is the coefficient of the identity Pauli matrix,...
void Rectify()
Re-adjust components to eliminate small deviations from |Q| = 1 orthonormality.
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...
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
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 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 X axis by the angle of rotation.
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
Scalar Angle() const
Angle of rotation.
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Scalar Angle() const
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...
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(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...
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Scalar Angle() const
Angle of rotation.
Scalar SinAngle() const
Sine or Cosine of the rotation angle.
void convert(R1 const &, R2 const)
static void correctByPi(double &psi, double &phi)
Scalar math_cos(Scalar x)
Rotation3D::Scalar Scalar
Scalar math_sqrt(Scalar x)
Scalar math_asin(Scalar x)
Scalar math_acos(Scalar x)
Scalar math_atan2(Scalar x, Scalar y)
Scalar math_fabs(Scalar x)
Scalar math_sin(Scalar x)