pairinteraction
A Rydberg Interaction Calculator
euler.test.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 Pairinteraction Developers
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
5
6#include <array>
7#include <doctest/doctest.h>
8
9namespace pairinteraction {
10DOCTEST_TEST_CASE("construction of rotation matrixes") {
11 auto rotator = euler::get_rotation_matrix<double>({0, 0, 1}, {0, 1, 0});
12 auto rotator_reference = Eigen::Matrix3<double>::Identity();
13 DOCTEST_CHECK((rotator - rotator_reference).norm() == 0);
14
15 rotator = euler::get_rotation_matrix<double>({0, 0, 1}, {1, 1, 0});
16 auto y_axis = Eigen::Vector3<double>{0, 1, 0};
17 auto rotated_y_axis = rotator * y_axis;
18 auto rotated_y_axis_reference = Eigen::Vector3<double>{1, 1, 0}.normalized();
19 DOCTEST_CHECK((rotated_y_axis - rotated_y_axis_reference).norm() == 0);
20
21 rotator = euler::get_rotation_matrix<double>({1, 0, 0}, {0, 1, 0});
22 auto z_axis = Eigen::Vector3<double>{0, 0, 1};
23 auto rotated_z_axis = rotator * z_axis;
24 auto rotated_z_axis_reference = Eigen::Vector3<double>{1, 0, 0};
25 DOCTEST_CHECK((rotated_z_axis - rotated_z_axis_reference).norm() == 0);
26
27 std::string error_msg = "The z-axis and the y-axis are not orhogonal.";
28 DOCTEST_CHECK_THROWS_WITH_AS(euler::get_rotation_matrix<double>({0, 0, 1}, {0, 1, 1});
29 , error_msg.c_str(), std::runtime_error);
30}
31
32DOCTEST_TEST_CASE("construction of zyz euler angles") {
33 constexpr double PI = 3.141592653589793238462643383279502884;
34
35 auto euler_angles = euler::get_euler_angles<double>({1, 1, 0}, {0, 0, 1});
36 std::array<double, 3> euler_angles_reference{0.25 * PI, 0.5 * PI, 0.5 * PI};
37 DOCTEST_CHECK(std::abs(euler_angles[0] - euler_angles_reference[0]) +
38 std::abs(euler_angles[1] - euler_angles_reference[1]) +
39 std::abs(euler_angles[2] - euler_angles_reference[2]) <=
40 1e-6);
41}
42} // namespace pairinteraction
Matrix< Type, 3, 1 > Vector3
Matrix< Type, 3, 3 > Matrix3
DOCTEST_TEST_CASE("create a basis for strontium 88")