File indexing completed on 2025-01-18 09:11:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/detail/AnnulusBoundsHelper.hpp"
0010
0011 #include "Acts/Surfaces/AnnulusBounds.hpp"
0012 #include "Acts/Utilities/VectorHelpers.hpp"
0013
0014 #include <numbers>
0015
0016 namespace Acts::detail {
0017
0018 std::tuple<std::shared_ptr<AnnulusBounds>, Transform3>
0019 AnnulusBoundsHelper::create(const Transform3& transform, double rMin,
0020 double rMax, std::vector<Vector2> vertices) {
0021 using Line2D = Eigen::Hyperplane<double, 2>;
0022
0023
0024 std::vector<std::pair<Vector2, Vector2>> boundLines;
0025 for (std::size_t i = 0; i < vertices.size(); ++i) {
0026 Vector2 a = vertices.at(i);
0027 Vector2 b = vertices.at((i + 1) % vertices.size());
0028 Vector2 ab = b - a;
0029 double phi = VectorHelpers::phi(ab);
0030
0031 if (std::abs(phi) > 3 * std::numbers::pi / 4. ||
0032 std::abs(phi) < std::numbers::pi / 4.) {
0033 if (a.norm() < b.norm()) {
0034 boundLines.push_back(std::make_pair(a, b));
0035 } else {
0036 boundLines.push_back(std::make_pair(b, a));
0037 }
0038 }
0039 }
0040
0041 if (boundLines.size() != 2) {
0042 throw std::logic_error(
0043 "Input DiscPoly bounds type does not have sensible edges.");
0044 }
0045
0046 Line2D lA = Line2D::Through(boundLines[0].first, boundLines[0].second);
0047 Line2D lB = Line2D::Through(boundLines[1].first, boundLines[1].second);
0048 Vector2 ix = lA.intersection(lB);
0049
0050 const Eigen::Translation3d originTranslation(ix.x(), ix.y(), 0.);
0051 const Vector2 originShift = -ix;
0052
0053
0054 Transform3 boundsTransform = transform * originTranslation;
0055
0056 double phi1 = VectorHelpers::phi(boundLines[0].second - boundLines[0].first);
0057 double phi2 = VectorHelpers::phi(boundLines[1].second - boundLines[1].first);
0058 double phiMax = std::max(phi1, phi2);
0059 double phiMin = std::min(phi1, phi2);
0060 double phiShift = 0.;
0061
0062
0063 auto annulusBounds = std::make_shared<AnnulusBounds>(
0064 rMin, rMax, phiMin, phiMax, originShift, phiShift);
0065
0066 return {annulusBounds, boundsTransform};
0067 }
0068
0069 }