|
||||
File indexing completed on 2025-01-18 10:05:57
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file orange/transform/detail/TransformTranslator.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/math/ArrayOperators.hh" 0011 #include "geocel/Types.hh" 0012 #include "orange/MatrixUtils.hh" 0013 0014 #include "../NoTransformation.hh" 0015 #include "../Transformation.hh" 0016 #include "../Translation.hh" 0017 0018 namespace celeritas 0019 { 0020 namespace detail 0021 { 0022 //---------------------------------------------------------------------------// 0023 /*! 0024 * Apply a translation to a transform to get another transform. 0025 * 0026 * An instance of this class applies a daughter-to-parent translation to 0027 * another transformation: the translation needed to relocate a "lower" 0028 * universe to a new coordinate system in the "higher" universe. 0029 * 0030 * Given a transform operator \b T defined \f[ 0031 \mathbf{T} x = \mathbf{R} x + t 0032 * \f] 0033 * and a translation operator defined \f[ 0034 \mathbf{\tilde T} x = x + t 0035 * \f] 0036 * where \f$ \mathbf{R} = \mathbf{I} \f$ is the implicit rotation matrix for 0037 * a translation, this operation returns a new transform 0038 * \f[ 0039 \mathbf{T}' = \mathbf{\tilde T}_A \mathbf{T}_B 0040 * \f] 0041 * where \f$\mathbf{\tilde T}_A\f$ is the constructor argument, \b T_B is the 0042 argument passed to the call operator, 0043 * and the \f$\mathbf{T}'\f$ is the return value. 0044 * The resulting transform has rotation 0045 * \f[ 0046 \mathbf{R}' = \mathbf{R}_B 0047 * \f] 0048 * and translation 0049 * \f[ 0050 \mathbf{t}' = \mathbf{t}_B + \mathbf{t}_A 0051 * \f] 0052 */ 0053 class TransformTranslator 0054 { 0055 public: 0056 //@{ 0057 //! \name Type aliases 0058 using Mat3 = SquareMatrixReal3; 0059 //@} 0060 0061 public: 0062 //! Construct with the new reference frame of the translation 0063 explicit TransformTranslator(Translation const& tr) : tr_{tr} {} 0064 0065 //// TRANSFORMATIONS //// 0066 0067 //! Transform an identity 0068 Translation const& operator()(NoTransformation const&) const 0069 { 0070 return tr_; 0071 } 0072 0073 inline Transformation operator()(Mat3 const&) const; 0074 0075 inline Transformation operator()(Transformation const&) const; 0076 0077 inline Translation operator()(Translation const&) const; 0078 0079 private: 0080 Translation tr_; 0081 }; 0082 0083 //---------------------------------------------------------------------------// 0084 /*! 0085 * Apply a translation to a rotation matrix. 0086 */ 0087 Transformation TransformTranslator::operator()(Mat3 const& rot) const 0088 { 0089 return Transformation{rot, tr_.translation()}; 0090 } 0091 0092 //---------------------------------------------------------------------------// 0093 /*! 0094 * Apply a translation to a transform. 0095 */ 0096 Transformation TransformTranslator::operator()(Transformation const& tr) const 0097 { 0098 return Transformation{tr.rotation(), tr.translation() + tr_.translation()}; 0099 } 0100 0101 //---------------------------------------------------------------------------// 0102 /*! 0103 * Apply a translation to another translation. 0104 */ 0105 Translation TransformTranslator::operator()(Translation const& tl) const 0106 { 0107 return Translation{tl.translation() + tr_.translation()}; 0108 } 0109 0110 //---------------------------------------------------------------------------// 0111 } // namespace detail 0112 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |