0
\$\begingroup\$

Let's say I have min (0,0,0) and max (1,1,1). If I have 3 points, lets say

  • a (0.2,0.4,0.2)
  • b (-0.5,0.8,0.2)
  • c (2,0.3,0.1)

How would I go about calculating it those points are within the coordinates of min and max?

Note that I am using simple shapes such as Cubes and that I am going to use this for optimizations with octrees

\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

This is what we call an axis aligned bounding box (AABB) containment check:

bool IsInsideAABB(Point check, Point min, Point max) {
    return min.x <= check.x && check.x <= max.x
        && min.y <= check.y && check.y <= max.y
        && min.z <= check.z && check.z <= max.z;      
}

Depending on your application, you might want to count points exactly on one boundary or another to be outside the box - so you may want to replace some of the <= with <

See How should I do AABB::contains? for more on that.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .