32 return {sin(phi / 2), 0, 0, cos(phi / 2)};
37 return {0, sin(phi / 2), 0, cos(phi / 2)};
42 return {0, 0, sin(phi / 2), cos(phi / 2)};
50 return zrot * xrot * zrot2;
55 double m00 = (-1 + 2 *
x *
x + 2 *
s *
s);
56 double m02 = 2 * (
x *
z +
y *
s);
57 double m10 = 2 * (
y *
x +
z *
s);
58 double m12 = 2 * (
y *
z -
x *
s);
59 double m20 = 2 * (
z *
x -
y *
s);
60 double m21 = 2 * (
z *
y +
x *
s);
61 double m22 = (-1 + 2 *
z *
z + 2 *
s *
s);
63 const double beta = std::acos(m22);
65 if (std::abs(m22) == 1.0)
66 return {std::atan2(m10, m00),
beta, 0.};
67 return {std::atan2(m02, -m12),
beta, std::atan2(m20, m21)};
72 return {-
x, -
y, -
z,
s};
78 auto xf = (-1 + 2 *
x *
x + 2 *
s *
s) * v.x() + 2 * (
x *
y -
z *
s) * v.y()
79 + 2 * (
x *
z +
y *
s) * v.z();
80 auto yf = (-1 + 2 *
y *
y + 2 *
s *
s) * v.y() + 2 * (
y *
z -
x *
s) * v.z()
81 + 2 * (
y *
x +
z *
s) * v.x();
82 auto zf = (-1 + 2 *
z *
z + 2 *
s *
s) * v.z() + 2 * (
z *
x -
y *
s) * v.x()
83 + 2 * (
z *
y +
x *
s) * v.y();
88 template R3 RotMatrix::transformed<R3>(
const R3& v)
const;
89 template C3 RotMatrix::transformed<C3>(
const C3& v)
const;
97 template R3 RotMatrix::counterTransformed<R3>(
const R3& v)
const;
98 template C3 RotMatrix::counterTransformed<C3>(
const C3& v)
const;
102 return {
s * o.
x +
x * o.
s +
y * o.
z -
z * o.
y,
s * o.
y +
y * o.
s +
z * o.
x -
x * o.
z,
103 s * o.
z +
z * o.
s +
x * o.
y -
y * o.
x,
s * o.
s -
x * o.
x -
y * o.
y -
z * o.
z};
108 return x == o.
x &&
y == o.
y &&
z == o.
z &&
s == o.
s;
113 return x == 0 &&
y == 0 &&
z == 0;
118 return y == 0 &&
z == 0;
123 return z == 0 &&
x == 0;
128 return x == 0 &&
y == 0;
134 return 2 * atan2(
x,
s);
136 return 2 * atan2(
y,
s);
138 return 2 * atan2(
z,
s);
Declares class RotMatrix.
Rotation matrix in three dimensions. Represents group SO(3). Internal parameterization based on quate...
T counterTransformed(const T &v) const
Return transformed vector v.
RotMatrix()
Constructs unit transformation.
static RotMatrix EulerZXZ(double alpha, double beta, double gamma)
Creates rotation defined by Euler angles.
static RotMatrix AroundZ(double phi)
Creates rotation around z-axis.
static RotMatrix AroundY(double phi)
Creates rotation around y-axis.
RotMatrix operator*(const RotMatrix &) const
Composes two transformations.
static RotMatrix AroundX(double phi)
Creates rotation around x-axis.
bool isIdentity() const
Determine if the transformation is trivial (identity)
RotMatrix Inverse() const
Returns the inverse transformation.
std::optional< double > angleAroundCoordAxis(int iAxis) const
std::array< double, 3 > zxzEulerAngles() const
Calculates the Euler angles corresponding to the rotation.
T transformed(const T &v) const
Return transformed vector v.
bool operator==(const RotMatrix &) const
Provides equality operator.
double beta(double z, double w)