I have a situation where (due to floating point error) a ray that is known to hit a bounding box fails due to floating point error. (1e-8 or so)
Expanding the box is not an acceptable solution in my specific use case. However, if I could "snap" the ray to the box, that would work out well.
In order to do so, I need to find the shortest vector from a given ray to a bounding box. In 2 dimensions, that would look like this:
If I can get that red vector, I can add it to the origin and the ray will be shifted to the bounding box.
In 2D this is apparently relatively easy, as you can get distance between two lines like here, then find the smallest of the 4 lines and use that.
But in 3D I am not aware of how to do this. Does anyone know if there is a way?