0

I need to know the point on a line segment that is closest to an AABB. I know that the line definitely does not intersect the box.

As a possible simplification, one of the dimensions of the box is zero (most of the time) so finding the closest point on the line segment to one face is all that I need. (I could extend this to check all 6 faces of the AABB in the edge case)

Just to confirm

  • The line is not infinite, it is defined by two points
  • The box/face is also constrained and not infinite
allanmb
  • 321
  • 3
  • 14
  • Since this was asked in the holidays, I just thought I'd give it a quick bump to see if anyone has any ideas – allanmb Jan 06 '16 at 09:47

1 Answers1

0

I have found a possible solution to this. I find the closest point on each of the 12 edges of the box (assuming full 3D box) and I also clamp each end of the line segment to the box and evaluate the distance from the segment. I then choose the closest out of these 14 points which seems to work. The reason for the 2 additional clamp points is when the line segment is constrained within 2 dimensions of the box, e.g. think of a lollipop, the closest point is not on one of the edges in this example.

allanmb
  • 321
  • 3
  • 14