Back to home page

EIC code displayed by LXR

 
 

    


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

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/Ray.hpp"
0014 
0015 namespace Acts::Test {
0016 
0017 BOOST_AUTO_TEST_SUITE(Utilities)
0018 BOOST_AUTO_TEST_CASE(ray_construction) {
0019   // 2D
0020 
0021   using Vector2F = Eigen::Matrix<float, 2, 1>;
0022 
0023   boost::test_tools::output_test_stream output;
0024 
0025   Vector2F dir2(0.5, 0.5);
0026   Ray<float, 2> ray2({1, 1}, dir2);
0027   dir2.normalize();  // after passing to ray
0028 
0029   BOOST_CHECK_EQUAL(ray2.origin(), Vector2F(1, 1));
0030   CHECK_CLOSE_ABS(ray2.dir(), dir2, 1e-6);
0031   Vector2F idir2 = 1. / dir2.array();
0032   CHECK_CLOSE_ABS(ray2.idir().matrix(), idir2, 1e-6);
0033 
0034   ray2.toStream(output);
0035   BOOST_CHECK(!output.is_empty(true));
0036 
0037   // 3D
0038   using Vector3F = Eigen::Matrix<float, 3, 1>;
0039 
0040   Vector3F dir3(1, 2, 1);
0041   Ray<float, 3> ray3({1, 2, 3}, dir3);
0042   dir3.normalize();  // after passing to ray
0043 
0044   BOOST_CHECK_EQUAL(ray3.origin(), Vector3F(1, 2, 3));
0045   CHECK_CLOSE_ABS(ray3.dir(), dir3, 1e-6);
0046   CHECK_CLOSE_ABS(ray3.idir().matrix(), (1. / dir3.array()).matrix(), 1e-6);
0047 
0048   ray3.toStream(output);
0049   BOOST_CHECK(!output.is_empty(true));
0050 
0051   // compile draw call, doesn't actually test anything
0052   // PlyVisualization3D hlp;
0053   // ray3.draw(hlp);
0054 }
0055 BOOST_AUTO_TEST_SUITE_END()
0056 
0057 }  // namespace Acts::Test