File indexing completed on 2026-09-15 08:19:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/EllipseBounds.hpp"
0010
0011 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0012 #include "Acts/Utilities/MathHelpers.hpp"
0013 #include "Acts/Utilities/VectorHelpers.hpp"
0014 #include "Acts/Utilities/detail/OstreamStateGuard.hpp"
0015 #include "Acts/Utilities/detail/periodic.hpp"
0016
0017 #include <iomanip>
0018 #include <iostream>
0019 #include <stdexcept>
0020
0021 namespace Acts {
0022
0023 using VectorHelpers::perp;
0024 using VectorHelpers::phi;
0025
0026 std::vector<double> EllipseBounds::values() const {
0027 return {m_values.begin(), m_values.end()};
0028 }
0029
0030 void EllipseBounds::checkConsistency() noexcept(false) {
0031 if (get(eInnerRx) >= get(eOuterRx) || get(eInnerRx) < 0. ||
0032 get(eOuterRx) <= 0.) {
0033 throw std::invalid_argument("EllipseBounds: invalid along x axis");
0034 }
0035 if (get(eInnerRy) >= get(eOuterRy) || get(eInnerRy) < 0. ||
0036 get(eOuterRy) <= 0.) {
0037 throw std::invalid_argument("EllipseBounds: invalid along y axis.");
0038 }
0039 if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) {
0040 throw std::invalid_argument("EllipseBounds: invalid phi sector setup.");
0041 }
0042 if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0043 throw std::invalid_argument("EllipseBounds: invalid phi positioning.");
0044 }
0045 }
0046
0047 bool EllipseBounds::inside(const Vector2& lposition) const {
0048 double phi =
0049 detail::radian_sym(VectorHelpers::phi(lposition) - get(eAveragePhi));
0050 return (-get(eHalfPhiSector) <= phi) && (phi < get(eHalfPhiSector)) &&
0051 (square(lposition[eBoundLoc0] / get(eInnerRx)) +
0052 square(lposition[eBoundLoc1] / get(eInnerRy))) >= 1 &&
0053 (square(lposition[eBoundLoc0] / get(eOuterRx)) +
0054 square(lposition[eBoundLoc1] / get(eOuterRy))) < 1;
0055 }
0056
0057 Vector2 EllipseBounds::closestPoint(const Vector2& ,
0058 const SquareMatrix2& ) const {
0059 throw std::runtime_error(
0060 "EllipseBounds::closestPoint: This method is not implemented. See "
0061 "https://github.com/acts-project/acts/issues/4478 for details.");
0062 }
0063
0064 std::vector<Vector2> EllipseBounds::vertices(
0065 unsigned int quarterSegments) const {
0066 return detail::VerticesHelper::ellipsoidVertices(
0067 get(eInnerRx), get(eInnerRy), get(eOuterRx), get(eOuterRy),
0068 get(eAveragePhi), get(eHalfPhiSector), quarterSegments);
0069 }
0070
0071 const RectangleBounds& EllipseBounds::boundingBox() const {
0072 return m_boundingBox;
0073 }
0074
0075 Vector2 EllipseBounds::center() const {
0076
0077
0078 return Vector2::Zero();
0079 }
0080
0081 std::ostream& EllipseBounds::toStream(std::ostream& sl) const {
0082 detail::OstreamStateGuard guard{sl};
0083 sl << std::fixed << std::setprecision(7);
0084 sl << "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, "
0085 "outerRadius1, hPhiSector, averagePhi) = ";
0086 sl << "(" << get(eInnerRx) << ", " << get(eInnerRy) << ", " << get(eOuterRx)
0087 << ", " << get(eOuterRy) << ", " << get(eAveragePhi) << ", "
0088 << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
0089 return sl;
0090 }
0091
0092 }