Add lerp/unlerp for boxes
This commit is contained in:
parent
8780a2d7e5
commit
bcc908d064
1 changed files with 18 additions and 0 deletions
|
|
@ -305,4 +305,22 @@ namespace psemek::geom
|
|||
return b;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
point<T, N> lerp(box<T, N> const & b, vector<T, N> const & v)
|
||||
{
|
||||
point<T, N> p;
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
p[i] = lerp(b[i], v[i]);
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
vector<T, N> unlerp(box<T, N> const & b, point<T, N> const & p)
|
||||
{
|
||||
vector<T, N> v;
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
v[i] = unlerp(b[i], p[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue