File indexing completed on 2026-11-17 10:21:52
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <algorithm>
0010
0011 #include "corecel/cont/LdgSpan.hh"
0012 #include "corecel/math/Algorithms.hh"
0013 #include "corecel/math/ArrayOperators.hh"
0014 #include "orange/OrangeTypes.hh"
0015
0016 namespace celeritas
0017 {
0018
0019
0020
0021
0022
0023
0024
0025 class Translation
0026 {
0027 public:
0028
0029
0030 using StorageSpan = LdgSpan<real_type const, 3>;
0031
0032
0033
0034 static CELER_CONSTEXPR_FUNCTION TransformType transform_type()
0035 {
0036 return TransformType::translation;
0037 }
0038
0039 public:
0040
0041 explicit CELER_FUNCTION Translation() : tra_{0, 0, 0} {}
0042
0043
0044 explicit CELER_FUNCTION Translation(Real3 const& trans) : tra_(trans) {}
0045
0046
0047 explicit inline CELER_FUNCTION Translation(StorageSpan s);
0048
0049
0050
0051
0052 CELER_FORCEINLINE_FUNCTION Real3 const& translation() const
0053 {
0054 return tra_;
0055 }
0056
0057
0058 CELER_FUNCTION StorageSpan data() const { return {&tra_[0], 3}; }
0059
0060
0061
0062
0063 inline CELER_FUNCTION Real3 transform_up(Real3 const& pos) const;
0064
0065
0066 inline CELER_FUNCTION Real3 transform_down(Real3 const& parent_pos) const;
0067
0068
0069 inline CELER_FUNCTION Real3 const& rotate_up(Real3 const& d) const;
0070
0071
0072 inline CELER_FUNCTION Real3 const& rotate_down(Real3 const& d) const;
0073
0074
0075 Translation calc_inverse() const { return Translation{negate(tra_)}; }
0076
0077
0078
0079 friend bool operator==(Translation const& a, Translation const& b)
0080 {
0081 auto a_data = a.data();
0082 return std::equal(a_data.begin(), a_data.end(), b.data().begin());
0083 }
0084 friend bool operator!=(Translation const& a, Translation const& b)
0085 {
0086 return !(a == b);
0087 }
0088
0089
0090 private:
0091 Real3 tra_;
0092 };
0093
0094
0095
0096
0097
0098
0099
0100 CELER_FUNCTION Translation::Translation(StorageSpan s) : tra_{s[0], s[1], s[2]}
0101 {
0102 }
0103
0104
0105
0106
0107
0108 CELER_FORCEINLINE_FUNCTION Real3 Translation::transform_up(
0109 Real3 const& pos) const
0110 {
0111 return pos + tra_;
0112 }
0113
0114
0115
0116
0117
0118 CELER_FORCEINLINE_FUNCTION Real3 Translation::transform_down(
0119 Real3 const& parent_pos) const
0120 {
0121 return parent_pos - tra_;
0122 }
0123
0124
0125
0126
0127
0128 CELER_FORCEINLINE_FUNCTION Real3 const& Translation::rotate_up(
0129 Real3 const& d) const
0130 {
0131 return d;
0132 }
0133
0134
0135
0136
0137
0138 CELER_FORCEINLINE_FUNCTION Real3 const& Translation::rotate_down(
0139 Real3 const& d) const
0140 {
0141 return d;
0142 }
0143
0144
0145 }