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