|
|
|||
File indexing completed on 2025-12-15 09:42:21
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/PlanarBounds.hpp" 0013 #include "Acts/Surfaces/SurfaceBounds.hpp" 0014 0015 #include <array> 0016 #include <iosfwd> 0017 #include <vector> 0018 0019 namespace Acts { 0020 0021 /// @class RectangleBounds 0022 /// 0023 /// @image html RectangleBounds.gif 0024 /// 0025 /// Bounds for a rectangular, planar surface - it can be used to for 0026 /// rectangles that are symmetrically centered around (0./0.) and for 0027 /// generic shifted rectangles 0028 class RectangleBounds : public PlanarBounds { 0029 public: 0030 /// @enum BoundValues 0031 /// Enumeration for the bound values 0032 enum BoundValues : int { 0033 eMinX = 0, 0034 eMinY = 1, 0035 eMaxX = 2, 0036 eMaxY = 3, 0037 eSize = 4 0038 }; 0039 0040 /// Constructor with halflength in x and y - symmetric 0041 /// 0042 /// @param halfX halflength in X 0043 /// @param halfY halflength in Y 0044 RectangleBounds(double halfX, double halfY) noexcept(false) 0045 : m_min({-halfX, -halfY}), m_max({halfX, halfY}) { 0046 checkConsistency(); 0047 } 0048 0049 /// Constructor - from fixed size array - generic 0050 /// 0051 /// @param values The parameter values 0052 explicit RectangleBounds(const std::array<double, eSize>& values) noexcept( 0053 false) 0054 : m_min({values[eMinX], values[eMinY]}), 0055 m_max({values[eMaxX], values[eMaxY]}) { 0056 checkConsistency(); 0057 } 0058 0059 /// Constructor - from min/max - generic 0060 /// 0061 /// @param min The left bottom corner 0062 /// @param max The right top corning 0063 RectangleBounds(const Vector2& min, const Vector2& max) noexcept(false) 0064 : m_min(min), m_max(max) { 0065 checkConsistency(); 0066 } 0067 0068 /// @copydoc SurfaceBounds::type 0069 BoundsType type() const final { return eRectangle; } 0070 0071 /// @copydoc SurfaceBounds::values 0072 std::vector<double> values() const final; 0073 0074 /// @copydoc SurfaceBounds::inside 0075 bool inside(const Vector2& lposition) const final; 0076 0077 /// @copydoc SurfaceBounds::closestPoint 0078 Vector2 closestPoint(const Vector2& lposition, 0079 const SquareMatrix2& metric) const final; 0080 0081 using SurfaceBounds::inside; 0082 0083 /// Return the vertices 0084 /// 0085 /// @param quarterSegments is the number of segments used to describe curved 0086 /// segments in a quarter of the phi range. 0087 /// @note the number of segments is ignored in this representation 0088 /// 0089 /// @return vector for vertices in 2D 0090 std::vector<Vector2> vertices(unsigned int quarterSegments = 0u) const final; 0091 0092 // Bounding box representation 0093 const RectangleBounds& boundingBox() const final; 0094 0095 /// @copydoc SurfaceBounds::center 0096 /// @note For RectangleBounds: returns the geometric center (min + max) / 2 0097 Vector2 center() const final; 0098 0099 /// Output Method for std::ostream 0100 /// 0101 /// @param sl is the ostream for the dump 0102 /// @return Reference to the output stream after writing 0103 std::ostream& toStream(std::ostream& sl) const final; 0104 0105 /// Access to the bound values 0106 /// @param bValue the class nested enum for the array access 0107 /// @return The requested bound value 0108 double get(BoundValues bValue) const; 0109 0110 /// Access to the half length in X 0111 /// @return Half the width of the rectangle in X direction 0112 double halfLengthX() const { return 0.5 * (m_max.x() - m_min.x()); } 0113 0114 /// Access to the half length in Y 0115 /// @return Half the width of the rectangle in Y direction 0116 double halfLengthY() const { return 0.5 * (m_max.y() - m_min.y()); } 0117 0118 /// Get the min vertex defining the bounds 0119 /// @return The min vertex 0120 const Vector2& min() const { return m_min; } 0121 0122 /// Get the max vertex defining the bounds 0123 /// @return The max vertex 0124 const Vector2& max() const { return m_max; } 0125 0126 private: 0127 Vector2 m_min; 0128 Vector2 m_max; 0129 0130 /// Check the input values for consistency, will throw a logic_exception 0131 /// if consistency is not given 0132 void checkConsistency() noexcept(false); 0133 }; 0134 0135 } // 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 |
|