Skip to content

Commit

Permalink
lerp revisited
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Aug 22, 2023
1 parent 80d8173 commit 8814346
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/kyosu/functions/lerp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace kyosu
//! **Parameters**
//!
//! * `z0, z1` : Value to process.
//! * `t` : interpolation coefficient
//! * `t` : floating value interpolation coefficient.
//!
//! **Return value**
//!
Expand Down
21 changes: 9 additions & 12 deletions include/kyosu/types/impl/arithmetic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,42 +62,42 @@ namespace kyosu::_
}
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::ceil> const&, C const& c) noexcept
{
return C{kumi::map([](auto const& e) { return eve::ceil(e); }, c)};
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::floor> const&, C const& c) noexcept
{
return C{kumi::map([](auto const& e) { return eve::floor(e); }, c)};
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::nearest> const&, C const& c) noexcept
{
return C{kumi::map([](auto const& e) { return eve::nearest(e); }, c)};
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::trunc> const&, C const& c) noexcept
{
return C{kumi::map([](auto const& e) { return eve::trunc(e); }, c)};
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::frac> const&, C const& c) noexcept
{
return C{kumi::map([](auto const& e) { return eve::frac(e); }, c)};
}

template<concepts::cayley_dickson C>
template<typename C>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::sqr> const&, C c) noexcept
{
Expand Down Expand Up @@ -131,14 +131,11 @@ namespace kyosu::_
}

template<concepts::cayley_dickson C0, concepts::cayley_dickson C1, eve::ordered_value T>
// template<eve::value C0, eve::value C1, eve::ordered_value T>
KYOSU_FORCEINLINE constexpr
auto dispatch(eve::tag_of<kyosu::lerp> const&, C0 const & c0, C1 const & c1, T const & t) noexcept
-> as_cayley_dickson_t<C0,C1,T>
{
// using r_t = as_cayley_dickson_t<C0,C1,T>;
// return r_t{kumi::map([](auto const& e, auto const & f, auto const & g) { return eve::lerp(e, f, g); }, c0, c1, t)};
return c0+t*(c1-c0);
}
using r_t = as_cayley_dickson_t<C0,C1,T>;
return r_t{kumi::map([&t](auto const& e, auto const & f) { return eve::lerp(e, f, t); }, c0, c1)};
}

}

0 comments on commit 8814346

Please sign in to comment.