File indexing completed on 2025-01-18 09:11:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/EllipseBounds.hpp"
0010
0011 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0012 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0013 #include "Acts/Utilities/MathHelpers.hpp"
0014 #include "Acts/Utilities/VectorHelpers.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,
0048 const BoundaryTolerance& boundaryTolerance) const {
0049 if (boundaryTolerance.isInfinite()) {
0050 return true;
0051 }
0052
0053 if (auto absoluteBound = boundaryTolerance.asAbsoluteBoundOpt();
0054 absoluteBound.has_value()) {
0055 double tol0 = absoluteBound->tolerance0;
0056 double tol1 = absoluteBound->tolerance1;
0057
0058 double phi =
0059 detail::radian_sym(VectorHelpers::phi(lposition) - get(eAveragePhi));
0060 double phiHalf = get(eHalfPhiSector) + tol1;
0061
0062 bool insidePhi = (-phiHalf <= phi) && (phi < phiHalf);
0063 bool insideInner = (get(eInnerRx) <= tol0) || (get(eOuterRx) <= tol0) ||
0064 (1 < (square(lposition[0] / (get(eInnerRx) - tol0)) +
0065 square(lposition[1] / (get(eOuterRx) - tol0))));
0066 bool insideOuter = (square(lposition[0] / (get(eInnerRy) + tol0)) +
0067 square(lposition[1] / (get(eOuterRy) + tol0))) < 1;
0068 return insidePhi && insideInner && insideOuter;
0069 }
0070
0071 throw std::logic_error("Unsupported boundary check type");
0072 }
0073
0074 std::vector<Vector2> EllipseBounds::vertices(
0075 unsigned int quarterSegments) const {
0076 return detail::VerticesHelper::ellipsoidVertices(
0077 get(eInnerRx), get(eInnerRy), get(eOuterRx), get(eOuterRy),
0078 get(eAveragePhi), get(eHalfPhiSector), quarterSegments);
0079 }
0080
0081 const RectangleBounds& EllipseBounds::boundingBox() const {
0082 return m_boundingBox;
0083 }
0084
0085 std::ostream& EllipseBounds::toStream(std::ostream& sl) const {
0086 sl << std::setiosflags(std::ios::fixed);
0087 sl << std::setprecision(7);
0088 sl << "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, "
0089 "outerRadius1, hPhiSector, averagePhi) = ";
0090 sl << "(" << get(eInnerRx) << ", " << get(eInnerRy) << ", " << get(eOuterRx)
0091 << ", " << get(eOuterRy) << ", " << get(eAveragePhi) << ", "
0092 << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
0093 sl << std::setprecision(-1);
0094 return sl;
0095 }
0096
0097 }