Skip to content

Commit

Permalink
Issue: #26 Making Ray's tolerance handling exclusive and conform with…
Browse files Browse the repository at this point in the history
… RangeSearch
  • Loading branch information
attcs committed Apr 21, 2024
1 parent 4c3d89b commit 6807af4
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions octree.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,21 @@ namespace OrthoTree

static constexpr bool DoesBoxContainPoint(TBox const& box, TVector const& point, TGeometry tolerance = 0) noexcept
{
for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
if (!(Base::GetBoxMinC(box, dimensionID) - tolerance <= Base::GetPointC(point, dimensionID) &&
Base::GetPointC(point, dimensionID) <= Base::GetBoxMaxC(box, dimensionID) + tolerance))
return false;

if (tolerance != 0.0)
{
assert(tolerance > 0);
for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
if (!(Base::GetBoxMinC(box, dimensionID) - tolerance < Base::GetPointC(point, dimensionID) &&
Base::GetPointC(point, dimensionID) < Base::GetBoxMaxC(box, dimensionID) + tolerance))
return false;
}
else
{
for (dim_t dimensionID = 0; dimensionID < DIMENSION_NO; ++dimensionID)
if (!(Base::GetBoxMinC(box, dimensionID) <= Base::GetPointC(point, dimensionID) &&
Base::GetPointC(point, dimensionID) <= Base::GetBoxMaxC(box, dimensionID)))
return false;
}
return true;
}

Expand Down Expand Up @@ -460,11 +470,24 @@ namespace OrthoTree
autoc hComp = Base::GetPointC(rayHeading, dimensionID);
if (hComp == 0)
{
if (Base::GetBoxMaxC(box, dimensionID) + tolerance < Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;
if (tolerance != 0.0)
{
assert(tolerance > 0);
if (Base::GetBoxMaxC(box, dimensionID) + tolerance <= Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;

if (Base::GetBoxMinC(box, dimensionID) - tolerance > Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;
if (Base::GetBoxMinC(box, dimensionID) - tolerance >= Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;

}
else
{
if (Base::GetBoxMaxC(box, dimensionID) < Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;

if (Base::GetBoxMinC(box, dimensionID) > Base::GetPointC(rayBasePoint, dimensionID))
return std::nullopt;
}

minDistances[dimensionID] = -inf;
maxDistances[dimensionID] = +inf;
Expand Down

0 comments on commit 6807af4

Please sign in to comment.