File indexing completed on 2025-10-14 08:02:26
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Utilities/Frustum.hpp"
0013 #include "Acts/Visualization/PlyVisualization3D.hpp"
0014 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0015
0016 #include <algorithm>
0017 #include <array>
0018 #include <cmath>
0019 #include <numbers>
0020 #include <utility>
0021 #include <vector>
0022
0023 using namespace Acts;
0024
0025 namespace ActsTests {
0026
0027 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0028
0029 BOOST_AUTO_TEST_CASE(frustum_construction) {
0030 boost::test_tools::output_test_stream output;
0031
0032 using Vector2F = Eigen::Matrix<float, 2, 1>;
0033
0034 using Frustum2f2 = Frustum<float, 2, 2>;
0035 Frustum2f2 fr({1, 0}, {0, 2}, std::numbers::pi / 2.);
0036
0037 BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0));
0038 CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6);
0039
0040 const auto& normals = fr.normals();
0041 BOOST_CHECK_EQUAL(normals.size(), 3u);
0042
0043 fr.svg(output, 200, 200);
0044 BOOST_CHECK(!output.is_empty(true));
0045
0046 using Vector3F = Eigen::Matrix<float, 3, 1>;
0047
0048 using Frustum3f3 = Frustum<float, 3, 3>;
0049 Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.);
0050
0051 BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0));
0052 CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0053
0054 const auto& normals33 = fr33.normals();
0055 BOOST_CHECK_EQUAL(normals33.size(), 4u);
0056
0057 PlyVisualization3D<float> hlp;
0058
0059
0060
0061 using Frustum3f4 = Frustum<float, 3, 4>;
0062 Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.);
0063
0064 BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0));
0065 CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0066
0067 const auto& normals34 = fr34.normals();
0068 BOOST_CHECK_EQUAL(normals34.size(), 5u);
0069
0070
0071 }
0072 BOOST_AUTO_TEST_SUITE_END()
0073
0074 }