views:

352

answers:

4

Given a union of convex objects and a point p inside this union, how does one find the closest point on the (concave) surface of the union from p?

For what it's worth I can easily find the closest point on the surface of a single convex object, it's the union of several that's giving me problems.

EDIT: I'm terribly sorry, I meant the union of the objects and not the intersection :( Apologies to everyone who answered.

EDIT2: Here's a small image describing the situation courtesy AakashM, a is the closest point on the surface of A from O, b is the closest point on the surface of B from O and x is the point I'm actually looking for (O == p).

alt text

My objects are not polygonal objects but lines with radius (I think the term capsule is sometimes used for this but I don't know if this term is universally accepted).

A: 

I guess you'll have to calculate the closest points on the surface all single objects (gives you n points), then check for each point, if its inside all other objects (so its part of the surface of the intersection), and than find the closest one to p.

This algorithm uses the fact, that a point is on the surface of the intersections of n convex objects, if it's on the surface of one of these objects and inside all other objects (the surface of the intersection is made of little pieces of surfaces of the intersected objects...)

MartinStettner
ezod's right, you don't need to check if the closest point is inside the other objects, if p is guaranteed to be in the intersection ...
MartinStettner
That might not be correct for 3D objects: Think of a point in the center of a large sphere A. It might be closer to another small sphere B contained in A than to the surface of A.
Adam Matan
@Adam Matan: But the intersection of A and B would then presumably be B, and so it doesn't matter that the closest point on A is not in the intersection, because the closest point on B will be, and since that one will be closer overall, it's the only one we're interested in.
ezod
@Adam: The closest point of all closest points *must* be inside all other objects: Just imagine the straight line from **p** to this point: If the closest closest point would be outside some object, the line would have intersected this object's boundary and there would be a closer closest point. (sorry for using "close" so much, I suppose that's typical for computational geometry discussions :-) ...)
MartinStettner
+2  A: 

There may be a more efficient way, but the naive approach would be to simply find the closest point to p on each surface, then select the one with the smallest distance. Since p is inside the mutual intersection of all of the objects, this point is guaranteed to be on the intersection surface.

ezod
good point! +1 ...
MartinStettner
I don't think this is right. The desired point is *on the surface of the intersection*, which I take to mean that in my diagram at http://imgur.com/mKJhq.png we want not point a (the nearest on object A), nor point b (the nearest on object B), but point x.
AakashM
@AakashM: But point x can never be the closest point to point O (or p, according to the question) unless it is also the closest point on one of the surfaces. :)
ezod
ezod: The question changed from "intersection" to "union".
Jason Orendorff
Indeed, a considerably more difficult problem which I haven't a clue how to approach.
ezod
A: 

I don't know the tool and data structure you're working on, but for example in matlab when you intersect n polygons the result is a new polygon of intersection, and if you can easily find the closest point on the surface of a single convex object, then if the intersection polygon is concave you can triangulate for getting your convex objects.

Bass
And, of course, if the *n* polygons were concave, the intersection would be *guaranteed* to be concave. Unless matlab has numerical difficulties with the intersection. But I don't see the point about triangulation ...
MartinStettner
because he said that he can easily find the closest point on the surface of a single convex, but if the union is concave we can break it into convex polygons via triangulation.
Bass
A: 

(for the Union version)

Every concave point of the union is at the intersection of the boundary of two of your objects. So you can just compute all such intersection points, test if they are on the boundary of your union, and pick the closest to p.

You need more than that, though, as in the following situation (union of 2 rectangles)

+--------------------+
|                    |
+--------------------+
|         p          |
|                    |
|                    |
|                    |
|                    |
+--------------------+

The result you want is not a boundary intersection point, and it isn't the closest point to p for either rectangle individually. I'm not sure how to handle that case.

Keith Randall