44 double phi =
sqrt(vx * vx + vy * vy + vz * vz);
47 double factor =
sin(phi / 2.0) / phi;
48 double S0 =
cos(phi / 2.0);
49 double S1 = factor * vx;
50 double S2 = factor * vy;
51 double S3 = factor * vz;
53 R(0, 0) = 2.0 * (S1 * S1 + S0 * S0) - 1.0;
54 R(0, 1) = 2.0 * (S1 * S2 - S0 * S3);
55 R(0, 2) = 2.0 * (S1 * S3 + S0 * S2);
57 R(1, 0) = 2.0 * (S2 * S1 + S0 * S3);
58 R(1, 1) = 2.0 * (S2 * S2 + S0 * S0) - 1.0;
59 R(1, 2) = 2.0 * (S2 * S3 - S0 * S1);
61 R(2, 0) = 2.0 * (S3 * S1 - S0 * S2);
62 R(2, 1) = 2.0 * (S3 * S2 + S0 * S1);
63 R(2, 2) = 2.0 * (S3 * S3 + S0 * S0) - 1.0;
69 vx = (
R(2, 1) -
R(1, 2)) / 2.0;
70 vy = (
R(0, 2) -
R(2, 0)) / 2.0;
71 vz = (
R(1, 0) -
R(0, 1)) / 2.0;
72 double c = (
R(0, 0) +
R(1, 1) +
R(2, 2) - 1.0) / 2.0;
73 double s =
sqrt(vx * vx + vy * vy + vz * vz);
74 double phi =
atan2(s, c);
79 vx = (vx > 0.0 ? phi : (-phi)) *
sqrt(
std::max(
R(0, 0) - c, 0.0) / (1.0 - c));
80 vy = (vy > 0.0 ? phi : (-phi)) *
sqrt(
std::max(
R(1, 1) - c, 0.0) / (1.0 - c));
81 vz = (vz > 0.0 ? phi : (-phi)) *
sqrt(
std::max(
R(2, 2) - c, 0.0) / (1.0 - c));
83 double factor = phi / s;
101 for(
int i = 0; i < 3; i++) {
102 for(
int j = 0; j < 3; j++) {
103 inv.
R(i, j) =
R(j, i);
112 return (
R(0, 1) == 0.0) && (
R(1, 0) == 0.0) && (
R(0, 2) == 0.0) && (
R(2, 0) == 0.0);
117 return (
R(1, 2) == 0.0) && (
R(2, 1) == 0.0) && (
R(1, 0) == 0.0) && (
R(0, 1) == 0.0);
122 return (
R(2, 0) == 0.0) && (
R(0, 2) == 0.0) && (
R(2, 1) == 0.0) && (
R(1, 2) == 0.0);
133 result.
R(1, 1) = result.
R(2, 2) =
cos(angle);
134 result.
R(1, 2) = - (result.
R(2, 1) =
sin(angle));
141 result.
R(2, 2) = result.
R(0, 0) =
cos(angle);
142 result.
R(2, 0) = - (result.
R(0, 2) =
sin(angle));
149 result.
R(0, 0) = result.
R(1, 1) =
cos(angle);
150 result.
R(0, 1) = - (result.
R(1, 0) =
sin(angle));
bool isPureYRotation() const
Test for rotation.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Tps< T > sin(const Tps< T > &x)
Sine.
Rotation3D inverse() const
Inversion.
bool isPureZRotation() const
Test for rotation.
static Rotation3D Identity()
Make identity.
Rotation3D()
Default constructor.
constexpr double c
The velocity of light in m/s.
bool isPureXRotation() const
Test for rotation.
static Rotation3D ZRotation(double angle)
Make rotation.
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Tps< T > sqrt(const Tps< T > &x)
Square root.
static Rotation3D YRotation(double angle)
Make rotation.
Tps< T > cos(const Tps< T > &x)
Cosine.
static Rotation3D XRotation(double angle)
Make rotation.
Rotation in 3-dimensional space.
Vector3D getAxis() const
Get axis vector.