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
|
typename cruft::region<S,T>::point_t
|
||||||
cruft::region<S,T>::closest (point_t q) const
|
cruft::region<S,T>::closest (point_t q) const
|
||||||
{
|
{
|
||||||
point_t out;
|
return clamp (q, p, p + e);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -145,9 +138,7 @@ template <size_t S, typename T>
|
|||||||
typename region<S,T>::point_t
|
typename region<S,T>::point_t
|
||||||
region<S,T>::constrain (point_t q) const noexcept
|
region<S,T>::constrain (point_t q) const noexcept
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < S; ++i)
|
return closest (q);
|
||||||
q[i] = clamp (q[i], p[i], p[i] + e[i]);
|
|
||||||
return q;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user