Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:57

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Utilities/Frustum.hpp"
0014 #include "Acts/Visualization/PlyVisualization3D.hpp"
0015 
0016 #include <algorithm>
0017 #include <array>
0018 #include <cmath>
0019 #include <numbers>
0020 #include <utility>
0021 #include <vector>
0022 
0023 namespace Acts::Test {
0024 
0025 BOOST_AUTO_TEST_SUITE(Utilities)
0026 BOOST_AUTO_TEST_CASE(frustum_construction) {
0027   boost::test_tools::output_test_stream output;
0028 
0029   using Vector2F = Eigen::Matrix<float, 2, 1>;
0030 
0031   using Frustum2f2 = Frustum<float, 2, 2>;
0032   Frustum2f2 fr({1, 0}, {0, 2}, std::numbers::pi / 2.);
0033 
0034   BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0));
0035   CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6);
0036 
0037   const auto& normals = fr.normals();
0038   BOOST_CHECK_EQUAL(normals.size(), 3u);
0039 
0040   fr.svg(output, 200, 200);
0041   BOOST_CHECK(!output.is_empty(true));
0042 
0043   using Vector3F = Eigen::Matrix<float, 3, 1>;
0044 
0045   using Frustum3f3 = Frustum<float, 3, 3>;
0046   Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.);
0047 
0048   BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0));
0049   CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0050 
0051   const auto& normals33 = fr33.normals();
0052   BOOST_CHECK_EQUAL(normals33.size(), 4u);
0053 
0054   PlyVisualization3D<float> hlp;
0055   // compile call to draw, does not actually test anything
0056   // fr33.draw(hlp);
0057 
0058   using Frustum3f4 = Frustum<float, 3, 4>;
0059   Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.);
0060 
0061   BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0));
0062   CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
0063 
0064   const auto& normals34 = fr34.normals();
0065   BOOST_CHECK_EQUAL(normals34.size(), 5u);
0066 
0067   // fr34.draw(hlp);
0068 }
0069 BOOST_AUTO_TEST_SUITE_END()
0070 
0071 }  // namespace Acts::Test