region: correct the 'closest' query calculation
This commit is contained in:
parent
1a52f0dd58
commit
578a99a6ba
13
region.cpp
13
region.cpp
@ -113,14 +113,7 @@ template <size_t S, typename T>
|
||||
typename cruft::region<S,T>::point_t
|
||||
cruft::region<S,T>::closest (point_t q) const
|
||||
{
|
||||
point_t out;
|
||||
|
||||
for (size_t i = 0; i < S; ++i)
|
||||
out[i] = q[i] < p[i] ? p[i] :
|
||||
q[i] > p[i] ? p[i] + e[i] :
|
||||
q[i];
|
||||
|
||||
return out;
|
||||
return clamp (q, p, p + e);
|
||||
}
|
||||
|
||||
|
||||
@ -145,9 +138,7 @@ template <size_t S, typename T>
|
||||
typename region<S,T>::point_t
|
||||
region<S,T>::constrain (point_t q) const noexcept
|
||||
{
|
||||
for (size_t i = 0; i < S; ++i)
|
||||
q[i] = clamp (q[i], p[i], p[i] + e[i]);
|
||||
return q;
|
||||
return closest (q);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user