Added BoundingBox::contains(const vec_type& v, value_type epsilon) method with new epsilon parameter to make it easier to test for containment in the presence of numerical errors

This commit is contained in:
Robert Osfield 2013-11-18 12:45:04 +00:00
parent c194e92df8
commit 80c45ad46a

View File

@ -227,6 +227,15 @@ class BoundingBoxImpl
(v.y()>=_min.y() && v.y()<=_max.y()) &&
(v.z()>=_min.z() && v.z()<=_max.z());
}
/** Returns true if this bounding box contains the specified coordinate allowing for specific epsilon. */
inline bool contains(const vec_type& v, value_type epsilon) const
{
return valid() &&
((v.x()+epsilon)>=_min.x() && (v.x()-epsilon)<=_max.x()) &&
((v.y()+epsilon)>=_min.y() && (v.y()-epsilon)<=_max.y()) &&
((v.z()+epsilon)>=_min.z() && (v.z()-epsilon)<=_max.z());
}
};
typedef BoundingBoxImpl<Vec3f> BoundingBoxf;