![]() |
|
|||
File indexing completed on 2025-08-05 08:08:20
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/Definitions/Units.hpp" 0013 0014 namespace Acts::detail { 0015 /// @brief Auxiliary class to coherently sort Transforms and Vectors such that 0016 /// a strict ordering between two objects may be defined and hence 0017 /// a sorted map or set of these objects becomes possible. In the case of 0018 /// Vectors, the sorter compares the differences of each component. As 0019 /// soon as a difference exceeds the predefined translational tolerance 0020 /// threshold the < operator is assigned based on this difference. In the 0021 /// case of rotations, the three Euler angles of the rotation matrix are 0022 /// evaluated and compared in an analogous way 0023 class TransformComparator { 0024 public: 0025 /// @brief Default constructor setting the predefined tolerance values 0026 /// for translation & rotation 0027 TransformComparator() = default; 0028 /// @brief Constructor with an adaption of the translation & rotTolerance 0029 /// @param transTolerance: Tolerance value within the difference of the 0030 /// i-th component between two vectors is considered to be 0 0031 /// @param rotTolerance: Tolerance value within the difference of the 0032 /// i-th Euler angle between two Rotations is considered to be 0 0033 TransformComparator(const double transTolerance, const double rotTolerance); 0034 /// @brief Generic comparison function between two kSize-dimensional vectors 0035 /// Returns 0 if all components agree within the translational 0036 /// tolerance. As soon as one component differs, 1 is returned if the 0037 /// component from vector a is larger and otherwise -1 0038 /// @param a: Reference to the first vector to compare 0039 /// @param b: Reference to the second vector to compare 0040 template <unsigned int kSize> 0041 int compare(const Acts::ActsVector<kSize>& a, 0042 const Acts::ActsVector<kSize>& b) const { 0043 for (unsigned int i = 0; i < kSize; ++i) { 0044 const double diff = a[i] - b[i]; 0045 if (std::abs(diff) > m_tolTrans) { 0046 return diff > 0 ? 1 : -1; 0047 } 0048 } 0049 return 0; 0050 } 0051 /// @brief Brief compares the three Euler angles of the two rotation matrices 0052 /// If all angles agree within the rotational tolerance, 0 is returned. 0053 /// Otherwise, -1 or 1 is returned depending on whether the first 0054 /// differing i-th angle from a or b is larger. 0055 /// @param a: Reference to the first rotation matrix to compare 0056 /// @param b: Reference to the second rotation matrix to compare 0057 int compare(const Acts::RotationMatrix3& a, 0058 const Acts::RotationMatrix3& b) const; 0059 /// @brief Compares two transforms. First, it's checked whether the translational 0060 /// components between the two differ and if not the comparison between 0061 /// the two rotation matrices is returned 0062 /// @param a: Reference to the first transform to compare 0063 /// @param b: Reference to the second transform to compare 0064 int compare(const Acts::Transform3& a, const Acts::Transform3& b) const; 0065 0066 /// @brief Implementation of the < operator for Transforms 0067 bool operator()(const Acts::Transform3& a, const Acts::Transform3& b) const; 0068 /// @brief Implementation of the < operator for RotationMatrices 0069 bool operator()(const Acts::RotationMatrix3& a, 0070 const Acts::RotationMatrix3& b) const; 0071 /// @brief Implementation of the < operator for 3-vectors 0072 bool operator()(const Acts::Vector3& a, const Acts::Vector3& b) const; 0073 /// @brief Implementation of the < operator for 2-vectors 0074 bool operator()(const Acts::Vector2& a, const Acts::Vector2& b) const; 0075 0076 private: 0077 /** @brief Maximum tolerance per translational vector component */ 0078 double m_tolTrans{0.1 * Acts::UnitConstants::um}; 0079 /** @brief Maximum tolerance per euler angle */ 0080 double m_tolRot{0.01 * Acts::UnitConstants::mrad}; 0081 }; 0082 } // namespace Acts::detail
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |