File indexing completed on 2025-01-18 09:13:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0012 #include "Acts/Visualization/Interpolation3D.hpp"
0013
0014 #include <numbers>
0015
0016 namespace Acts::Test {
0017
0018 BOOST_AUTO_TEST_SUITE(Visualization)
0019
0020 BOOST_AUTO_TEST_CASE(SplineInterpolationEigen) {
0021
0022 double R = 10.;
0023 std::vector<Acts::Vector3> inputs;
0024
0025
0026 std::vector<Acts::Vector3> trajectory;
0027
0028
0029 trajectory = Acts::Interpolation3D::spline(inputs, 10);
0030 BOOST_CHECK(trajectory.empty());
0031
0032 for (double phi = 0; phi < 2 * std::numbers::pi;
0033 phi += std::numbers::pi / 4) {
0034 inputs.push_back(Acts::Vector3(R * cos(phi), R * sin(phi), 0.));
0035 }
0036
0037
0038 trajectory = Acts::Interpolation3D::spline(inputs, 1);
0039
0040 BOOST_CHECK_EQUAL(trajectory.size(), inputs.size());
0041
0042
0043 trajectory = Acts::Interpolation3D::spline(inputs, 12);
0044
0045 BOOST_CHECK_EQUAL(trajectory.size(), 12);
0046
0047 for (const auto& point : trajectory) {
0048
0049
0050 CHECK_CLOSE_ABS(point.norm(), R, 0.1);
0051
0052 CHECK_CLOSE_ABS(point.z(), 0., 0.1);
0053 }
0054 }
0055
0056 BOOST_AUTO_TEST_CASE(SplineInterpolationArray) {
0057
0058 std::vector<std::array<double, 3u>> inputs;
0059
0060 for (double x = 0; x < 10; x += 1) {
0061 inputs.push_back({x, x * x, 0.});
0062 }
0063
0064
0065 auto trajectory = Acts::Interpolation3D::spline(inputs, 100, true);
0066
0067
0068 constexpr bool isOutput =
0069 std::is_same_v<decltype(trajectory), decltype(inputs)>;
0070 BOOST_CHECK(isOutput);
0071
0072
0073 BOOST_CHECK_EQUAL(trajectory.size(), 108);
0074 }
0075
0076 BOOST_AUTO_TEST_CASE(SplineInterpolationErrors) {
0077 std::vector<std::array<double, 3u>> inputs;
0078
0079
0080 inputs.push_back({0., 0., 0.});
0081 auto result = Acts::Interpolation3D::spline(inputs, 10);
0082 BOOST_CHECK_EQUAL(result.size(), 1);
0083
0084
0085 inputs.push_back({1., 1., 1.});
0086 result = Acts::Interpolation3D::spline(inputs, 10);
0087 BOOST_CHECK_EQUAL(result.size(), 2);
0088 }
0089
0090 BOOST_AUTO_TEST_SUITE_END()
0091
0092 }