diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-03-20 18:33:31 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-03-20 18:33:31 +0100 |
| commit | 14320632fbf39237b5f2254ec1d312ce3c12d879 (patch) | |
| tree | d6ad720ba3f5912816e960f4fa146aafaeafe26a /lib/core/c++ | |
| parent | 2a5261cd719547686f283b2aeae004b589b69e32 (diff) | |
| download | libs-lbm-14320632fbf39237b5f2254ec1d312ce3c12d879.tar.gz | |
Wanted to finish n linearity today, but I guess I should be happy with
this
Diffstat (limited to 'lib/core/c++')
| -rw-r--r-- | lib/core/c++/math/n_linear.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/core/c++/math/n_linear.hpp b/lib/core/c++/math/n_linear.hpp index ac02da8..8fb0600 100644 --- a/lib/core/c++/math/n_linear.hpp +++ b/lib/core/c++/math/n_linear.hpp @@ -43,6 +43,25 @@ auto floor_index_from_position(const saw::data<sch::Vector<T,D>>& pos){ return position_to_index_and_fraction(pos).template get<0u>(); } +template<typename T, uint64_t D> +saw::data<sch::Tuple<sch::Vector<sch::UInt64,D>,sch::Vector<T,D>>> position_to_index_and_fraction_bounded( + const saw::data<sch::Vector<T,D>>& pos, + const saw::data<sch::Vector<sch::UInt64,D>>& bound) +{ + auto infr = position_to_index_and_fraction(pos); + auto& ind = infr.template get<0u>(); + auto& fra = infr.template get<1u>(); + for(uint64_t i = 0u; i < D; ++i){ + // If index is higher than bound. Set to bound and reset fraction + if((ind.at({{i}}).get()+1u) >= bound.at({{i}}).get()){ + ind.at({{i}}).set(bound.at({{i}}).get()-1u); + fra.at({{i}}) = {}; + } + } + return infr; +} + + template<typename FieldSchema, typename T, uint64_t D> auto n_linear_interpolate( const saw::data<FieldSchema>& field, const saw::data<sch::Vector<T,D>>& pos){ |
