![]() |
|
|||
File indexing completed on 2025-02-22 10:47:11
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 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/surf/detail/InvolutePoint.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <cmath> 0011 0012 #include "corecel/Types.hh" 0013 #include "corecel/cont/Array.hh" 0014 #include "orange/OrangeTypes.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace detail 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Find point on involute using involute equation. 0023 * 0024 * * \f[ 0025 * x = r_b (\cos(t+a) + t \sin(t+a)) 0026 * \f] 0027 * \f[ 0028 * y = r_b (\sin(t+a) - t \cos(t+a)) 0029 * \f] 0030 * 0031 */ 0032 class InvolutePoint 0033 { 0034 public: 0035 //!@{ 0036 //! \name Type alias 0037 using Real2 = Array<real_type, 2>; 0038 0039 public: 0040 // Construct involute from parameters 0041 inline CELER_FUNCTION InvolutePoint(real_type r_b, real_type a); 0042 0043 // Calculate point on an involute 0044 inline CELER_FUNCTION Real2 operator()(real_type theta) const; 0045 0046 //// ACCESSORS //// 0047 0048 //! Get involute parameters 0049 CELER_FUNCTION real_type r_b() const { return r_b_; } 0050 CELER_FUNCTION real_type a() const { return a_; } 0051 0052 private: 0053 //// DATA //// 0054 // Involute parameters 0055 real_type r_b_; 0056 real_type a_; 0057 }; 0058 0059 //---------------------------------------------------------------------------// 0060 // INLINE DEFINITIONS 0061 //---------------------------------------------------------------------------// 0062 /*! 0063 * Construct from involute parameters. 0064 */ 0065 CELER_FUNCTION InvolutePoint::InvolutePoint(real_type r_b, real_type a) 0066 : r_b_(r_b), a_(a) 0067 { 0068 CELER_EXPECT(r_b > 0); 0069 CELER_EXPECT(a >= 0); 0070 } 0071 0072 /*! 0073 * Calculate the point on an involute. 0074 */ 0075 CELER_FUNCTION Real2 InvolutePoint::operator()(real_type theta) const 0076 { 0077 real_type angle = theta + a_; 0078 Real2 point; 0079 // TODO: check that compiler avoids recomputing trig functions 0080 point[0] = r_b_ * (std::cos(angle) + theta * std::sin(angle)); 0081 point[1] = r_b_ * (std::sin(angle) - theta * std::cos(angle)); 0082 0083 return point; 0084 } 0085 //---------------------------------------------------------------------------// 0086 } // namespace detail 0087 } // 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 |
![]() ![]() |