Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FrustumTest.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FrustumTest.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/tools/output_test_stream.hpp>
10 #include <boost/test/unit_test.hpp>
11 
15 
16 #include <algorithm>
17 #include <array>
18 #include <cmath>
19 #include <utility>
20 #include <vector>
21 
22 using boost::test_tools::output_test_stream;
23 
24 namespace Acts {
25 namespace Test {
26 
27 BOOST_AUTO_TEST_SUITE(Utilities)
28 BOOST_AUTO_TEST_CASE(frustum_construction) {
29  output_test_stream output;
30 
31  using Vector2F = Eigen::Matrix<float, 2, 1>;
32 
33  using Frustum2f2 = Frustum<float, 2, 2>;
34  Frustum2f2 fr({1, 0}, {0, 2}, M_PI / 2.);
35 
36  BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0));
37  CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6);
38 
39  const auto& normals = fr.normals();
40  BOOST_CHECK_EQUAL(normals.size(), 3u);
41 
42  fr.svg(output, 200, 200);
43  BOOST_CHECK(!output.is_empty(true));
44 
45  using Vector3F = Eigen::Matrix<float, 3, 1>;
46 
47  using Frustum3f3 = Frustum<float, 3, 3>;
48  Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
49 
50  BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0));
51  CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
52 
53  const auto& normals33 = fr33.normals();
54  BOOST_CHECK_EQUAL(normals33.size(), 4u);
55 
57  // compile call to draw, does not actually test anything
58  // fr33.draw(hlp);
59 
60  using Frustum3f4 = Frustum<float, 3, 4>;
61  Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, M_PI / 2.);
62 
63  BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0));
64  CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6);
65 
66  const auto& normals34 = fr34.normals();
67  BOOST_CHECK_EQUAL(normals34.size(), 5u);
68 
69  // fr34.draw(hlp);
70 }
71 BOOST_AUTO_TEST_SUITE_END()
72 
73 } // namespace Test
74 } // namespace Acts