Add scalar-interval distance function
This commit is contained in:
parent
d891d21ec2
commit
4f0b804656
1 changed files with 8 additions and 0 deletions
|
|
@ -9,6 +9,14 @@
|
|||
namespace psemek::geom
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
T distance(T const & x, interval<T> const & i)
|
||||
{
|
||||
if (i.min <= x && x <= i.max)
|
||||
return T{0};
|
||||
return std::min(std::abs(x - i.min), std::abs(x - i.max));
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
T distance(point<T, N> const & p, box<T, N> const & b)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue