|
|
|||
File indexing completed on 2026-08-26 08:18:37
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/Surfaces/BoundaryTolerance.hpp" 0013 0014 #include <cmath> 0015 #include <ostream> 0016 0017 namespace Acts { 0018 0019 /// @class SurfaceBounds 0020 /// 0021 /// Interface for surface bounds. 0022 /// 0023 /// Surface bounds provide: 0024 /// - inside() checks 0025 /// - distance to boundary calculations 0026 /// - the BoundsType and a set of parameters to simplify persistency 0027 /// 0028 class SurfaceBounds { 0029 public: 0030 /// @enum BoundsType 0031 /// This is nested to the SurfaceBounds, as also VolumeBounds will have 0032 /// Bounds Type. 0033 enum BoundsType : int { 0034 eCone = 0, 0035 eCylinder = 1, 0036 eDiamond = 2, 0037 eDisc = 3, 0038 eEllipse = 4, 0039 eLine = 5, 0040 eRectangle = 6, 0041 eTrapezoid = 7, 0042 eTriangle = 8, 0043 eDiscTrapezoid = 9, 0044 eConvexPolygon = 10, 0045 eAnnulus = 11, 0046 eBoundless = 12, 0047 ePoint = 13, 0048 eOther = 14 0049 }; 0050 0051 virtual ~SurfaceBounds() = default; 0052 0053 /// Return the bounds type - for persistency optimization 0054 /// @return the bounds type 0055 virtual BoundsType type() const = 0; 0056 0057 /// Check if the bound coordinates are cartesian 0058 /// @return true if the bound coordinates are cartesian 0059 virtual bool isCartesian() const = 0; 0060 0061 /// Computes the bound to cartesian jacobian at a given local position 0062 /// @param lposition is the local position at which the jacobian is computed 0063 /// @return the bound to cartesian jacobian 0064 virtual SquareMatrix2 boundToCartesianJacobian( 0065 const Vector2& lposition) const = 0; 0066 0067 /// Computes the bound to cartesian metric at a given local position 0068 /// @param lposition is the local position at which the metric is computed 0069 /// @return the bound to cartesian metric 0070 virtual SquareMatrix2 boundToCartesianMetric( 0071 const Vector2& lposition) const = 0; 0072 0073 /// Access method for bound values, this is a dynamically sized 0074 /// vector containing the parameters needed to describe these bounds 0075 /// @return of the stored values for this SurfaceBounds object 0076 virtual std::vector<double> values() const = 0; 0077 0078 /// Inside check for the bounds object 0079 /// @param lposition is the local position 0080 /// @return true if the local position is inside the bounds 0081 virtual bool inside(const Vector2& lposition) const = 0; 0082 0083 /// Calculates the closest point on the bounds to a given local position 0084 /// @param lposition is the local position 0085 /// @param metric to be used for the distance calculation 0086 /// @return the closest point on the bounds 0087 virtual Vector2 closestPoint(const Vector2& lposition, 0088 const SquareMatrix2& metric) const = 0; 0089 0090 /// Calculates the distance to the bounds from a given local position 0091 /// @param lposition is the local position 0092 /// @return the distance to the bounds 0093 virtual double distance(const Vector2& lposition) const { 0094 SquareMatrix2 metric = boundToCartesianMetric(lposition); 0095 0096 Vector2 closest = closestPoint(lposition, metric); 0097 Vector2 diff = closest - lposition; 0098 return std::sqrt((diff.transpose() * metric * diff)(0, 0)); 0099 } 0100 0101 /// Inside check for the bounds object given a boundary tolerance. 0102 /// @param lposition is the local position 0103 /// @param boundaryTolerance is the boundary tolerance object 0104 /// @return true if the local position is inside the bounds and tolerance 0105 virtual bool inside(const Vector2& lposition, 0106 const BoundaryTolerance& boundaryTolerance) const; 0107 0108 /// Calculate the center of the surface bounds in local coordinates 0109 /// 0110 /// This method returns a representative center point of the bounds region. 0111 /// The exact definition varies by bounds type and coordinate system: 0112 /// 0113 /// **Cartesian bounds** (Rectangle, Diamond, Trapezoid): 0114 /// - Returns the geometric center or center of symmetry 0115 /// - For symmetric shapes: center of bounding box or origin (0,0) 0116 /// 0117 /// **Polar/Cylindrical bounds** (Radial, Cylinder, Cone): 0118 /// - Returns (r, phi) where r is average radius, phi is average angle 0119 /// - Coordinates are in the bounds' natural coordinate system 0120 /// 0121 /// **Complex bounds** (Annulus, ConvexPolygon): 0122 /// - Annulus: Pre-calculated from corner vertices (accounts for coordinate 0123 /// transforms) 0124 /// - Polygon: Average of all vertices (vertex centroid, not area centroid) 0125 /// 0126 /// **Infinite bounds**: Returns conceptual center at (0,0) 0127 /// 0128 /// @note The returned point is guaranteed to be a reasonable representative 0129 /// center, but may not be the true geometric centroid for all shapes. 0130 /// 0131 /// @return Vector2 representing the center position in local coordinates 0132 virtual Vector2 center() const = 0; 0133 0134 /// Output Method for std::ostream, to be overloaded by child classes 0135 /// @param os is the outstream in which the string dump is done 0136 /// @return Modified ostream for chaining 0137 virtual std::ostream& toStream(std::ostream& os) const = 0; 0138 0139 friend bool operator==(const SurfaceBounds& lhs, const SurfaceBounds& rhs) { 0140 if (&lhs == &rhs) { 0141 return true; 0142 } 0143 return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values()); 0144 } 0145 0146 friend std::ostream& operator<<(std::ostream& os, const SurfaceBounds& sb) { 0147 return sb.toStream(os); 0148 } 0149 }; 0150 0151 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|