region: add distance2
This commit is contained in:
parent
16fc2effb2
commit
11a077f63d
21
region.hpp
21
region.hpp
@ -209,6 +209,27 @@ namespace util {
|
||||
}
|
||||
|
||||
|
||||
template <size_t S, typename T>
|
||||
T
|
||||
distance2 (region<S,T> r, point<S,T> p)
|
||||
{
|
||||
auto const clamped = util::max (
|
||||
util::min (p, r.p + r.e),
|
||||
r.p
|
||||
);
|
||||
|
||||
return distance2 (r.p, clamped);
|
||||
}
|
||||
|
||||
|
||||
template <size_t S, typename T>
|
||||
T
|
||||
distance2 (point<S,T> p, region<S,T> r)
|
||||
{
|
||||
return distance2 (r, p);
|
||||
}
|
||||
|
||||
|
||||
template <size_t S, typename T, typename GeneratorT>
|
||||
util::point<S,T>
|
||||
sample (region<S,T> shape, GeneratorT &&gen)
|
||||
|
Loading…
Reference in New Issue
Block a user