File indexing completed on 2025-12-16 09:25:09
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/Surfaces/detail/LineHelper.hpp"
0015 #include "Acts/Surfaces/detail/PlanarHelper.hpp"
0016 #include "Acts/Utilities/UnitVectors.hpp"
0017
0018 #include <format>
0019
0020 using namespace Acts;
0021
0022 namespace ActsTests {
0023
0024 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0025
0026 BOOST_AUTO_TEST_CASE(checkPlaneIsection) {
0027 using namespace PlanarHelper;
0028
0029 const Vector3 pointInPlane{561., 0., 0.};
0030 const Vector3 planeNormal{Vector3::UnitX()};
0031
0032 const Vector3 extPoint = pointInPlane + 50. * planeNormal;
0033 const Vector3 lineDir = Vector3{1., 5., 0.}.normalized();
0034
0035 const Vector3 crossPoint = intersectPlane(extPoint, lineDir, planeNormal,
0036 planeNormal.dot(pointInPlane))
0037 .position();
0038
0039 BOOST_CHECK_LE(std::abs(pointInPlane.x() - crossPoint.x()),
0040 std::numeric_limits<float>::epsilon());
0041 BOOST_CHECK_LE(std::abs(pointInPlane.y() - crossPoint.y() - 250.),
0042 std::numeric_limits<float>::epsilon());
0043 }
0044
0045 BOOST_AUTO_TEST_CASE(lineDistance) {
0046 using namespace detail::LineHelper;
0047 using namespace UnitLiterals;
0048 const Vector3 posA{100, 0., 0.};
0049 const Vector3 posB{100, 50, 0.};
0050 constexpr double tolerance = 1.e-12;
0051
0052 const double parallelTest =
0053 signedDistance(posA, Vector3::UnitZ(), posB, Vector3::UnitZ());
0054 BOOST_CHECK_LE(std::abs(parallelTest - 50), tolerance);
0055 std::cout << __FILE__ << ":" << __LINE__
0056 << " - Passed test between two parallel crossing lines: "
0057 << parallelTest << std::endl;
0058
0059 const double orthogonalTest =
0060 std::abs(signedDistance(posA, Vector3::UnitX(), posB, Vector3::UnitZ()));
0061 BOOST_CHECK_LE(std::abs(orthogonalTest - 50), tolerance);
0062 std::cout << __FILE__ << ":" << __LINE__
0063 << " - Passed test between two orthogonal lines: " << orthogonalTest
0064 << std::endl;
0065
0066 constexpr double angleXY = 36. * 1_degree;
0067 const Vector3 dirInXY{makeDirectionFromPhiTheta(0., angleXY)};
0068 const double planeXYTest = signedDistance(posA, dirInXY, posB, dirInXY);
0069 BOOST_CHECK_LE(std::abs(planeXYTest - 50.), tolerance);
0070 const double planeXYTest1 = signedDistance(posA, dirInXY, posB, dirInXY);
0071 BOOST_CHECK_LE(std::abs(std::abs(planeXYTest1) - 50.), tolerance);
0072 std::cout << __FILE__ << ":" << __LINE__
0073 << " - Passed test between two parallel lines in the x-y plane: "
0074 << planeXYTest << std::endl;
0075
0076 const Vector3 plumbDir{-dirInXY.z(), 0., dirInXY.x()};
0077
0078
0079 const Vector3 extDir =
0080 (5. * dirInXY + 21. * plumbDir.cross(dirInXY)).normalized();
0081
0082 BOOST_CHECK_LE(extDir.dot(plumbDir), tolerance);
0083 BOOST_CHECK_LE(plumbDir.dot(dirInXY), tolerance);
0084
0085
0086 const Vector3 extPoint =
0087 posA + 50. * dirInXY + 50. * plumbDir + 400. * extDir;
0088
0089 const Vector3 closePointExt =
0090 lineIntersect(posA, dirInXY, extPoint, extDir).position();
0091 BOOST_CHECK_LE((posA + 50. * dirInXY + 50. * plumbDir - closePointExt).norm(),
0092 tolerance);
0093
0094 const Vector3 closePointXY =
0095 lineIntersect(extPoint, extDir, posA, dirInXY).position();
0096 BOOST_CHECK_LE((posA + 50. * dirInXY - closePointXY).norm(), tolerance);
0097
0098 BOOST_CHECK_LE(std::abs((closePointXY - closePointExt).norm() - 50.),
0099 tolerance);
0100
0101 const double extLineDist = signedDistance(posA, dirInXY, extPoint, extDir);
0102 BOOST_CHECK_LE(std::abs(extLineDist - 50.), tolerance);
0103 const double extLineDist1 = signedDistance(posA, dirInXY, extPoint, extDir);
0104 BOOST_CHECK_LE(std::abs(extLineDist1 - 50.), tolerance);
0105
0106 const double crossLines =
0107 signedDistance(extPoint + 525. * dirInXY, dirInXY, extPoint, extDir);
0108
0109
0110
0111 BOOST_CHECK_LE(std::abs(crossLines), 1e-5);
0112 }
0113 BOOST_AUTO_TEST_SUITE_END()
0114
0115 }