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