|
|
|||
File indexing completed on 2026-11-25 09:02:29
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/Surfaces/detail/CurvatureCorrection.hpp" 0012 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" 0013 0014 namespace Acts::detail::CylinderHelper { 0015 0016 /// Solve |position + s*direction|^2 = radius^2 in the transverse plane. 0017 /// Inputs may be local xy vectors or global vectors crossed with the cylinder 0018 /// axis. Keeping that choice with the caller avoids redundant transformations. 0019 template <typename PositionDerived, typename DirectionDerived> 0020 inline RealQuadraticEquation intersectionSolver( 0021 const Eigen::MatrixBase<PositionDerived>& position, 0022 const Eigen::MatrixBase<DirectionDerived>& direction, double radius) { 0023 return RealQuadraticEquation(direction.squaredNorm(), 0024 2. * direction.dot(position), 0025 position.squaredNorm() - radius * radius); 0026 } 0027 0028 /// Inputs are in the cylinder's local frame. Preserve arrival at the actual 0029 /// starting position; only predicted crossings receive a correction. 0030 inline std::optional<CurvatureCorrection> correctIntersection( 0031 double s, const Vector3& seed, const Vector3& direction, 0032 const Vector3& curvature, double curvatureNorm, double radius, 0033 double tolerance) { 0034 if (std::abs(s) < std::abs(tolerance)) { 0035 return std::nullopt; 0036 } 0037 // n = (seed.x, seed.y, 0)/R. The common 1/R cancels in ds; using 0038 // the actual seed avoids cancellation from sharing expanded dot products 0039 // between distant ray roots. The incidence guard is scaled by R too. 0040 return correctCurvatureIntersection( 0041 s, seed, direction, curvature, seed.head<2>().dot(direction.head<2>()), 0042 seed.head<2>().dot(curvature.head<2>()), curvatureNorm, radius); 0043 } 0044 0045 /// Keep projection policy internal: subsequent numerical optimizations can 0046 /// replace this implementation without changing Surface or navigation APIs. 0047 /// Corrected cylinder points lie on the seed's tangent plane. Radially project 0048 /// them back onto the cylinder, leaving z and the estimated path unchanged. 0049 /// A bound-coordinate Jacobian could instead map the tangential displacement 0050 /// u to an arc-length increment u. Radial projection gives R*atan(u/R), so the 0051 /// two agree to first order but differ beyond it. Keep the Cartesian correction 0052 /// and radial projection together to preserve the current approximation. 0053 /// This does not make the trajectory approximation second-order accurate. 0054 struct CylinderProjectionScales { 0055 double first = 0.; 0056 double second = 0.; 0057 }; 0058 0059 /// Exact paired radial scales; zero marks an invalid projection. 0060 inline CylinderProjectionScales cylinderProjectionScales( 0061 const std::optional<CurvatureCorrection>& first, 0062 const std::optional<CurvatureCorrection>& second, double radius) { 0063 // Calculate both independent lengths before dividing. This allows the 0064 // compiler to overlap the two exact projections, without SIMD or an 0065 // approximate reciprocal square root. Zero marks a failed projection. 0066 const double r1 = first ? first->position.head<2>().norm() : 0.; 0067 const double r2 = second ? second->position.head<2>().norm() : 0.; 0068 return {r1 > 0. && std::isfinite(r1) ? radius / r1 : 0., 0069 r2 > 0. && std::isfinite(r2) ? radius / r2 : 0.}; 0070 } 0071 0072 } // namespace Acts::detail::CylinderHelper
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|