File indexing completed on 2026-05-22 07:48:43
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/Definitions/Direction.hpp"
0013 #include "Acts/Geometry/BoundarySurfaceFace.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
0016 #include "Acts/Surfaces/PlaneSurface.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Utilities/BoundingBox.hpp"
0019 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0020
0021 #include <cmath>
0022 #include <memory>
0023 #include <numbers>
0024 #include <utility>
0025 #include <vector>
0026
0027 using namespace Acts;
0028
0029 namespace ActsTests {
0030
0031 BOOST_AUTO_TEST_SUITE(GeometrySuite)
0032
0033 BOOST_AUTO_TEST_CASE(bounding_box_creation) {
0034 float tol = 1e-4;
0035
0036 TrapezoidVolumeBounds tvb(5, 10, 8, 4);
0037
0038 auto bb = tvb.boundingBox();
0039 CHECK_CLOSE_ABS(bb.max(), Vector3(10, 8, 4), tol);
0040 CHECK_CLOSE_ABS(bb.min(), Vector3(-10, -8, -4), tol);
0041
0042 Transform3 trf;
0043
0044 trf = Translation3(Vector3(0, 30, 20));
0045
0046 bb = tvb.boundingBox(&trf);
0047 CHECK_CLOSE_ABS(bb.max(), Vector3(10, 38, 24), tol);
0048 CHECK_CLOSE_ABS(bb.min(), Vector3(-10, 22, 16), tol);
0049
0050 trf = AngleAxis3(std::numbers::pi / 2., Vector3(-2, 4, 5).normalized());
0051
0052 bb = tvb.boundingBox(&trf);
0053 CHECK_CLOSE_ABS(bb.max(), Vector3(9.32577, 11.4906, 11.5777), tol);
0054 CHECK_CLOSE_ABS(bb.min(), Vector3(-9.77021, -8.65268, -9.23688), tol);
0055 }
0056
0057 BOOST_AUTO_TEST_CASE(TrapezoidVolumeBoundarySurfaces) {
0058 TrapezoidVolumeBounds tvb(5, 10, 8, 4);
0059
0060 auto tvbOrientedSurfaces = tvb.orientedSurfaces(Transform3::Identity());
0061 BOOST_CHECK_EQUAL(tvbOrientedSurfaces.size(), 6);
0062
0063 auto geoCtx = GeometryContext::dangerouslyDefaultConstruct();
0064
0065 for (auto& os : tvbOrientedSurfaces) {
0066 auto osCenter = os.surface->center(geoCtx);
0067 const auto* pSurface = dynamic_cast<const PlaneSurface*>(os.surface.get());
0068 BOOST_REQUIRE_MESSAGE(pSurface != nullptr,
0069 "The surface is not a plane surface");
0070 auto osNormal = pSurface->normal(geoCtx);
0071
0072 Vector3 insideTvb = osCenter + os.direction * osNormal;
0073 Vector3 outsideTvb = osCenter - os.direction * osNormal;
0074 BOOST_CHECK(tvb.inside(insideTvb));
0075 BOOST_CHECK(!tvb.inside(outsideTvb));
0076 }
0077
0078 Vector3 xaxis(1., 0., 0.);
0079 Vector3 yaxis(0., 1., 0.);
0080 Vector3 zaxis(0., 0., 1.);
0081
0082
0083 auto nFaceXY = tvbOrientedSurfaces[negativeFaceXY]
0084 .surface->localToGlobalTransform(geoCtx)
0085 .rotation();
0086 BOOST_CHECK(nFaceXY.col(0).isApprox(xaxis));
0087 BOOST_CHECK(nFaceXY.col(1).isApprox(yaxis));
0088 BOOST_CHECK(nFaceXY.col(2).isApprox(zaxis));
0089
0090 auto pFaceXY = tvbOrientedSurfaces[positiveFaceXY]
0091 .surface->localToGlobalTransform(geoCtx)
0092 .rotation();
0093 BOOST_CHECK(pFaceXY.col(0).isApprox(xaxis));
0094 BOOST_CHECK(pFaceXY.col(1).isApprox(yaxis));
0095 BOOST_CHECK(pFaceXY.col(2).isApprox(zaxis));
0096
0097 auto nFaceZX = tvbOrientedSurfaces[negativeFaceZX]
0098 .surface->localToGlobalTransform(geoCtx)
0099 .rotation();
0100 BOOST_CHECK(nFaceZX.col(0).isApprox(zaxis));
0101 BOOST_CHECK(nFaceZX.col(1).isApprox(xaxis));
0102 BOOST_CHECK(nFaceZX.col(2).isApprox(yaxis));
0103
0104 auto pFaceZX = tvbOrientedSurfaces[positiveFaceZX]
0105 .surface->localToGlobalTransform(geoCtx)
0106 .rotation();
0107 BOOST_CHECK(pFaceZX.col(0).isApprox(zaxis));
0108 BOOST_CHECK(pFaceZX.col(1).isApprox(xaxis));
0109 BOOST_CHECK(pFaceZX.col(2).isApprox(yaxis));
0110 }
0111
0112 BOOST_AUTO_TEST_SUITE_END()
0113
0114 }