File indexing completed on 2025-01-18 09:12:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/RectangleBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0016
0017 #include <algorithm>
0018 #include <array>
0019 #include <limits>
0020 #include <stdexcept>
0021 #include <vector>
0022
0023 const double inf = std::numeric_limits<double>::infinity();
0024
0025 namespace Acts::Test {
0026
0027 BOOST_AUTO_TEST_SUITE(Surfaces)
0028
0029
0030 BOOST_AUTO_TEST_CASE(RectangleBoundsConstruction) {
0031 const double halfX = 10.;
0032 const double halfY = 5.;
0033 RectangleBounds twentyByTenRectangle(halfX, halfY);
0034 BOOST_CHECK_EQUAL(twentyByTenRectangle.type(),
0035 Acts::SurfaceBounds::eRectangle);
0036
0037
0038 const double zeroHalfX = 0.;
0039 const double zeroHalfY = 0.;
0040 const double infHalfX = inf;
0041 const double infHalfY = inf;
0042
0043
0044 RectangleBounds zeroDimensionsRectangle(zeroHalfX, zeroHalfY);
0045 BOOST_CHECK_EQUAL(zeroDimensionsRectangle.type(),
0046 Acts::SurfaceBounds::eRectangle);
0047
0048
0049 RectangleBounds infinite(infHalfX, infHalfY);
0050 BOOST_CHECK_EQUAL(infinite.type(), Acts::SurfaceBounds::eRectangle);
0051 }
0052
0053
0054 BOOST_AUTO_TEST_CASE(RectangleBoundsRecreation) {
0055 const double halfX = 10.;
0056 const double halfY = 2.;
0057
0058 RectangleBounds original(halfX, halfY);
0059
0060 auto valvector = original.values();
0061 std::array<double, RectangleBounds::eSize> values{};
0062 std::copy_n(valvector.begin(), RectangleBounds::eSize, values.begin());
0063 RectangleBounds recreated(values);
0064 BOOST_CHECK_EQUAL(original, recreated);
0065 }
0066
0067
0068 BOOST_AUTO_TEST_CASE(RadialBoundsException) {
0069 const double halfX = 10.;
0070 const double halfY = 2.;
0071
0072
0073 BOOST_CHECK_THROW(RectangleBounds(-halfX, halfY), std::logic_error);
0074
0075
0076 BOOST_CHECK_THROW(RectangleBounds(halfX, -halfY), std::logic_error);
0077 }
0078
0079
0080 BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(1e-10))
0081 BOOST_AUTO_TEST_CASE(RectangleBoundsProperties) {
0082 const double halfX = 10.;
0083 const double halfY = 5.;
0084
0085 RectangleBounds rect(halfX, halfY);
0086 BOOST_CHECK_EQUAL(rect.halfLengthX(), halfX);
0087 BOOST_CHECK_EQUAL(rect.halfLengthY(), halfY);
0088
0089 CHECK_CLOSE_ABS(rect.min(), Vector2(-halfX, -halfY), 1e-6);
0090 CHECK_CLOSE_ABS(rect.max(), Vector2(halfX, halfY), 1e-6);
0091
0092 const std::vector<Vector2> coords = {
0093 {-halfX, -halfY}, {halfX, -halfY}, {halfX, halfY}, {-halfX, halfY}};
0094
0095 const auto& rectVertices = rect.vertices();
0096 BOOST_CHECK_EQUAL_COLLECTIONS(coords.cbegin(), coords.cend(),
0097 rectVertices.cbegin(), rectVertices.cend());
0098 const Vector2 pointA{1., 1.};
0099
0100 BoundaryTolerance tolerance = BoundaryTolerance::None();
0101 BOOST_CHECK(rect.inside(pointA, tolerance));
0102 }
0103 BOOST_AUTO_TEST_CASE(RectangleBoundsAssignment) {
0104 const double halfX = 10.;
0105 const double halfY = 2.;
0106
0107 RectangleBounds rectA(halfX, halfY);
0108 RectangleBounds rectB(0., 0.);
0109 rectB = rectA;
0110 const auto originalVertices = rectA.vertices();
0111 const auto assignedVertices = rectB.vertices();
0112 BOOST_CHECK_EQUAL_COLLECTIONS(
0113 originalVertices.cbegin(), originalVertices.cend(),
0114 assignedVertices.cbegin(), assignedVertices.cend());
0115 }
0116
0117 BOOST_AUTO_TEST_SUITE_END()
0118
0119 }