|
|
|||
File indexing completed on 2025-11-21 09:49:50
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file orange/transform/detail/TransformTransformer.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "geocel/Types.hh" 0010 #include "orange/MatrixUtils.hh" 0011 0012 #include "../NoTransformation.hh" 0013 #include "../Transformation.hh" 0014 #include "../Translation.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace detail 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Apply a transformation to another transformation. 0023 * 0024 * An instance of this class applies a daughter-to-parent translation to 0025 * another transformation: the translation needed to relocate a "lower" 0026 * universe to a new coordinate system in the "higher" universe. 0027 * 0028 * Given a transform operator \b T defined \f[ 0029 \mathbf{T}x = \mathbf{R} x + t 0030 * \f] 0031 * this operation returns a new transform 0032 * \f[ 0033 \mathbf{T}' = \mathbf{T}_A \mathbf{T}_B 0034 * \f] 0035 * where \f$\mathbf{T}_A\f$ is the constructor argument 0036 * (the operator itself), \f$\mathbf{T}_b\f$ is the argument passed to the call 0037 * operator, and the \f$\mathbf{T}'\f$ is the return value. 0038 * The new transform has rotation 0039 * \f[ 0040 \mathbf{R}' = \mathbf{R}_A\mathbf{R}_B 0041 * \f] 0042 * and translation 0043 * \f[ 0044 \mathbf{t}' = \mathbf{R}_A\mathbf{t}_B + \mathbf{t}_A 0045 * \f] 0046 */ 0047 class TransformTransformer 0048 { 0049 public: 0050 //@{ 0051 //! \name Type aliases 0052 using Mat3 = SquareMatrix<real_type, 3>; 0053 //@} 0054 0055 public: 0056 //! Construct with the new reference frame of the transformation 0057 explicit TransformTransformer(Transformation const& tr) : tr_{tr} {} 0058 0059 //! Transform an identity 0060 Transformation const& operator()(NoTransformation const&) const 0061 { 0062 return tr_; 0063 } 0064 0065 //!@{ 0066 //! Transform a transformation 0067 inline Transformation operator()(Mat3 const&) const; 0068 inline Transformation operator()(Transformation const&) const; 0069 inline Transformation operator()(Translation const&) const; 0070 //!@} 0071 0072 private: 0073 Transformation tr_; 0074 }; 0075 0076 //---------------------------------------------------------------------------// 0077 /*! 0078 * Apply a transformation to a rotation matrix. 0079 */ 0080 Transformation TransformTransformer::operator()(Mat3 const& other) const 0081 { 0082 return Transformation{gemm(tr_.rotation(), other), tr_.translation()}; 0083 } 0084 0085 //---------------------------------------------------------------------------// 0086 /*! 0087 * Apply a transformation to a transform. 0088 */ 0089 Transformation 0090 TransformTransformer::operator()(Transformation const& other) const 0091 { 0092 return Transformation{gemm(tr_.rotation(), other.rotation()), 0093 tr_.transform_up(other.translation())}; 0094 } 0095 0096 //---------------------------------------------------------------------------// 0097 /*! 0098 * Apply a transformation to a translation. 0099 */ 0100 Transformation TransformTransformer::operator()(Translation const& other) const 0101 { 0102 return Transformation{tr_.rotation(), 0103 tr_.transform_up(other.translation())}; 0104 } 0105 0106 //---------------------------------------------------------------------------// 0107 } // namespace detail 0108 } // 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 |
|