File indexing completed on 2025-06-06 08:07:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0012
0013 namespace Acts::detail {
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 inline bool insideAlignedBox(const Vector2& lowerLeft,
0025 const Vector2& upperRight,
0026 const BoundaryTolerance& tolerance,
0027 const Vector2& point,
0028 const std::optional<SquareMatrix2>& jacobianOpt) {
0029 if (tolerance.isInfinite()) {
0030 return true;
0031 }
0032
0033 if (detail::VerticesHelper::isInsideRectangle(point, lowerLeft, upperRight)) {
0034 return true;
0035 }
0036
0037 if (!tolerance.hasTolerance()) {
0038 return false;
0039 }
0040
0041 Vector2 closestPoint;
0042
0043 if (!tolerance.hasMetric(jacobianOpt.has_value())) {
0044 closestPoint =
0045 detail::VerticesHelper::computeEuclideanClosestPointOnRectangle(
0046 point, lowerLeft, upperRight);
0047 } else {
0048
0049
0050
0051 std::array<Vector2, 4> vertices = {{lowerLeft,
0052 {upperRight[0], lowerLeft[1]},
0053 upperRight,
0054 {lowerLeft[0], upperRight[1]}}};
0055
0056 SquareMatrix2 metric = tolerance.getMetric(jacobianOpt);
0057
0058 closestPoint = detail::VerticesHelper::computeClosestPointOnPolygon(
0059 point, vertices, metric);
0060 }
0061
0062 Vector2 distance = closestPoint - point;
0063
0064 return tolerance.isTolerated(distance, jacobianOpt);
0065 }
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 template <typename Vector2Container>
0076 inline bool insidePolygon(const Vector2Container& vertices,
0077 const BoundaryTolerance& tolerance,
0078 const Vector2& point,
0079 const std::optional<SquareMatrix2>& jacobianOpt) {
0080 if (tolerance.isInfinite()) {
0081
0082 return true;
0083 }
0084
0085 if (detail::VerticesHelper::isInsidePolygon(point, vertices)) {
0086
0087 return true;
0088 }
0089
0090 if (!tolerance.hasTolerance()) {
0091
0092
0093
0094
0095
0096 return false;
0097 }
0098
0099
0100
0101
0102
0103
0104 SquareMatrix2 metric = tolerance.getMetric(jacobianOpt);
0105
0106
0107
0108 auto closestPoint = detail::VerticesHelper::computeClosestPointOnPolygon(
0109 point, vertices, metric);
0110
0111 Vector2 distance = closestPoint - point;
0112
0113 return tolerance.isTolerated(distance, jacobianOpt);
0114 }
0115
0116 }