Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:03

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/Intersection.hpp"
0013 
0014 /// @brief Helpers for planar surfaces that share the same maths
0015 namespace Acts::PlanarHelper {
0016 
0017 /// Intersection with a planar surface
0018 ///
0019 /// @param transform The 3D affine transform that places the surface
0020 /// @param position The starting position for the intersection
0021 /// @param direction The starting direction for the intersection
0022 ///
0023 /// @return The intersection
0024 inline Intersection3D intersect(const Transform3& transform,
0025                                 const Vector3& position,
0026                                 const Vector3& direction, double tolerance) {
0027   // Get the matrix from the transform (faster access)
0028   const auto& tMatrix = transform.matrix();
0029   const Vector3 pnormal = tMatrix.block<3, 1>(0, 2).transpose();
0030   const Vector3 pcenter = tMatrix.block<3, 1>(0, 3).transpose();
0031   // It is solvable, so go on
0032   double denom = direction.dot(pnormal);
0033   if (denom != 0.0) {
0034     // Translate that into a path
0035     double path = (pnormal.dot((pcenter - position))) / (denom);
0036     // Is valid hence either on surface or reachable
0037     IntersectionStatus status = std::abs(path) < std::abs(tolerance)
0038                                     ? IntersectionStatus::onSurface
0039                                     : IntersectionStatus::reachable;
0040     // Return the intersection
0041     return Intersection3D{(position + path * direction), path, status};
0042   }
0043   return Intersection3D::invalid();
0044 }
0045 
0046 }  // namespace Acts::PlanarHelper