28template <
typename Real>
30 std::array<Real, 3> to_y_axis) {
31 static_assert(std::is_floating_point_v<Real>);
33 auto to_z_axis_mapped = Eigen::Map<Eigen::Vector3<Real>>(to_z_axis.data()).normalized();
34 auto to_y_axis_mapped = Eigen::Map<Eigen::Vector3<Real>>(to_y_axis.data()).normalized();
36 auto scale = to_z_axis_mapped.norm() * to_y_axis_mapped.norm();
37 auto numerical_precision = 100 * scale * std::numeric_limits<Real>::epsilon();
39 if (std::abs(to_z_axis_mapped.dot(to_y_axis_mapped)) > numerical_precision) {
40 throw std::runtime_error(
"The z-axis and the y-axis are not orhogonal.");
44 rotator << to_y_axis_mapped.cross(to_z_axis_mapped), to_y_axis_mapped, to_z_axis_mapped;
63template <
typename Real>
65 std::array<Real, 3> to_y_axis) {
66 static_assert(std::is_floating_point_v<Real>);
69 std::array<Real, 3> euler_zyz{};
70 Eigen::Map<Eigen::Vector3<Real>>(euler_zyz.data()) = rotator.eulerAngles(2, 1, 2);
Matrix< Type, 3, 3 > Matrix3
std::array< Real, 3 > get_euler_angles(std::array< Real, 3 > to_z_axis, std::array< Real, 3 > to_y_axis)
Extract the Euler angles alpha, beta, gamma.
Eigen::Matrix3< Real > get_rotation_matrix(std::array< Real, 3 > to_z_axis, std::array< Real, 3 > to_y_axis)
Build a matrix that rotates the coordinate system to the new z-axis and y-axis.