From 31c97bc0659e325bf1990a228805b000dca16853 Mon Sep 17 00:00:00 2001 From: Tom Mudway Date: Wed, 28 Jun 2017 15:01:31 -0400 Subject: [PATCH] Added contails_tol function contains_tol tests to see if a point is inside a box within a certain tolerance. This is essential if you are finding intersection points as it allows for you to eliminate any issues of a point on the box's face not being detected as inside due to floating point errors. The default tolerance is set to 1e-14 for this reason. --- structures/Space.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/structures/Space.h b/structures/Space.h index 00312a6..439b369 100644 --- a/structures/Space.h +++ b/structures/Space.h @@ -192,6 +192,14 @@ class Space { && -box.axis2_length <= b && b <= box.axis2_length && -box.axis3_length <= c && c <= box.axis3_length; } + + // Check if point is contained by box with certain tolerence + template + static inline bool contains_tol(const OrientedBox& b, const Vector3D& v, double tol = -1e-14){ + return v.x - b.lesser_corner.x >= tol && b.greater_corner.x - v.x >= tol + && v.y - b.lesser_corner.y >= tol && b.greater_corner.y - v.y >= tol + && v.z - b.lesser_corner.z >= tol && b.greater_corner.z - v.z >= tol; + } /// Do two oriented boxes intersect template