File indexing completed on 2025-09-18 08:11:50
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/Intersection.hpp"
0013
0014
0015 namespace Acts::PlanarHelper {
0016
0017
0018
0019
0020
0021
0022 inline Intersection3D intersectPlane(const Vector3& linePos,
0023 const Vector3& lineDir,
0024 const Vector3& planeNorm,
0025 const double offset) {
0026
0027
0028
0029 const double normDot = planeNorm.dot(lineDir);
0030 if (std::abs(normDot) < std::numeric_limits<double>::epsilon()) {
0031 return Intersection3D::invalid();
0032 }
0033 const double path = (offset - linePos.dot(planeNorm)) / normDot;
0034 return Intersection3D{linePos + path * lineDir, path,
0035 IntersectionStatus::onSurface};
0036 }
0037
0038
0039
0040
0041
0042 inline Intersection3D intersectPlane(const Vector3& linePos,
0043 const Vector3& lineDir,
0044 const Vector3& planeNorm,
0045 const Vector3& planePoint) {
0046 return intersectPlane(linePos, lineDir, planeNorm, planePoint.dot(planeNorm));
0047 }
0048
0049
0050
0051
0052
0053
0054
0055
0056 inline Intersection3D intersect(const Transform3& transform,
0057 const Vector3& position,
0058 const Vector3& direction, double tolerance) {
0059
0060 const auto& tMatrix = transform.matrix();
0061 const Vector3 pnormal = tMatrix.block<3, 1>(0, 2).transpose();
0062 const Vector3 pcenter = tMatrix.block<3, 1>(0, 3).transpose();
0063
0064 double denom = direction.dot(pnormal);
0065 if (denom != 0.0) {
0066
0067 double path = (pnormal.dot((pcenter - position))) / (denom);
0068
0069 IntersectionStatus status = std::abs(path) < std::abs(tolerance)
0070 ? IntersectionStatus::onSurface
0071 : IntersectionStatus::reachable;
0072
0073 return Intersection3D{(position + path * direction), path, status};
0074 }
0075 return Intersection3D::invalid();
0076 }
0077
0078 }