Hi there,
i nailed down the closest point from box to plane successfully, now its getting much more complicated...
I have a line segment defined by a world position and two local points which may not be perpendicular.
Also i got a box defined by a world position and a local radius vector.
What must i do, to determine the closest point from the box to the line segment in 2D, including its normal vector??
Using the same approach i did for the plane does not work at all, because the normal changes when the center of the box is outside the line area. Same concept like circle vs line segment - which is much easier, because of the nature of just subtracting the radius from the projected distance.
Does someone have some ideas how to get this done?
The only way i could think of to get this solved is using separating axis theorem to project the line and the box against the following normals:
From A (Line segment): Its perpendicular from (B-A) / |(B-A)|
From B (Box): Two fixed unit vector (1.0, 0.0) and (0.0, 1.0).
In theory this should get me the smallest distance including its normal and from there it may be the same way i did with plane vs box...