Hey folks!
Does anyone know of a "relatively" simple method of determining the minimum distance between a point and a quadrilateral? I currently have the co-ordinates of the point, and the co-ordinates of the four quadrilateral vertices. I'm hoping to use it to determine whether a sphere intersects the quadrilateral or not, by determining the minimum distance between the sphere's centre and the quadrilateral, and checking whether it is smaller than the sphere's radius.
I have found a method that checks the minimum distance between the point and the vertex co-ordinates, and then the distance between the point and the quadrilateral line segments.. then taking the minimum. However, the above check would then return "false" if the sphere passed straight through the centre of the quadrilateral, and the sphere's radius small enough to pass through without vertex or line segment contact.
In short, I'm looking to determine the minimum distance between a point and a quadrilateral, taking into account the surface of the quadrilateral (as oppose to just it's edges).
Any help is very much appreciated! Thanyou
Minimum Distance between a Point and a Quadrilateral
The collision manager can find intersections between spheres and triangles, but I think it may have the same problem.
one way to do it, you could transform the point into quad space (rotate/translate it so it is above the quad). If the absolute height (Y) is less than your sphere radius, and on the X/Z plane the point is inside the 2d quad (that is, if it is on the same side [left/right] of all lines which make up one of the 2d triangles, then it is inside)... then there is an intersection with the face at the X/Z position of the point (transform it back).
if not inside, you just use the line3d.getClosestPoint on the 4 edges.
there's probably a faster, mathematical way to do this somewhere on the internet, so you'd be best off searching google before listening to my ramblings!
one way to do it, you could transform the point into quad space (rotate/translate it so it is above the quad). If the absolute height (Y) is less than your sphere radius, and on the X/Z plane the point is inside the 2d quad (that is, if it is on the same side [left/right] of all lines which make up one of the 2d triangles, then it is inside)... then there is an intersection with the face at the X/Z position of the point (transform it back).
if not inside, you just use the line3d.getClosestPoint on the 4 edges.
there's probably a faster, mathematical way to do this somewhere on the internet, so you'd be best off searching google before listening to my ramblings!