Minimum Distance between a Point and a Quadrilateral

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Minimum Distance between a Point and a Quadrilateral

Post by Helderash »

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 :)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

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!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply