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