Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-16 08:16:51

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 <Eigen/Core>
0012 #include <Eigen/Geometry>
0013 
0014 namespace Acts::detail {
0015 
0016 /// Compute the quaternion that rotates vector @p a onto vector @p b.
0017 ///
0018 /// This wraps @c Eigen::Quaternion::setFromTwoVectors, whose implementation
0019 /// instantiates a (fixed-size) @c Eigen::JacobiSVD. That SVD instantiation is
0020 /// very expensive in compiler memory (~0.5 GB per translation unit). Declaring
0021 /// this helper here and providing the definition out-of-line (explicitly
0022 /// instantiated for @c float and @c double in QuaternionFromTwoVectors.cpp)
0023 /// means the SVD is instantiated once in the Acts core library instead of in
0024 /// every translation unit that needs it.
0025 ///
0026 /// @param a the source vector
0027 /// @param b the target vector
0028 /// @return the quaternion rotating @p a onto @p b
0029 Eigen::Quaternion<float> quaternionFromTwoVectors(
0030     const Eigen::Matrix<float, 3, 1>& a, const Eigen::Matrix<float, 3, 1>& b);
0031 
0032 /// Compute the quaternion that rotates vector @p a onto vector @p b.
0033 ///
0034 /// This wraps @c Eigen::Quaternion::setFromTwoVectors, whose implementation
0035 /// instantiates a (fixed-size) @c Eigen::JacobiSVD. That SVD instantiation is
0036 /// very expensive in compiler memory (~0.5 GB per translation unit). Declaring
0037 /// this helper here and providing the definition out-of-line (explicitly
0038 /// instantiated for @c float and @c double in QuaternionFromTwoVectors.cpp)
0039 /// means the SVD is instantiated once in the Acts core library instead of in
0040 /// every translation unit that needs it.
0041 ///
0042 /// @param a the source vector
0043 /// @param b the target vector
0044 /// @return the quaternion rotating @p a onto @p b
0045 Eigen::Quaternion<double> quaternionFromTwoVectors(
0046     const Eigen::Matrix<double, 3, 1>& a, const Eigen::Matrix<double, 3, 1>& b);
0047 
0048 }  // namespace Acts::detail