If I have Shape S and Point P. How do I find the point on the
perimeter of S that is closest to P?
Luc The Perverse - 22 Oct 2006 00:54 GMT
> If I have Shape S and Point P. How do I find the point on the
> perimeter of S that is closest to P?
Um? Distance formula/brute force?
--
LTP
:)
Chris Uppal - 22 Oct 2006 12:11 GMT
> If I have Shape S and Point P. How do I find the point on the
> perimeter of S that is closest to P?
Too little information even to guess. Some questions:
How are the shapes defined.? Lines connecting points ? Splines ? Some other
kind of curve ?
Or maybe there's just a list of basic shapes to choose from (rectangle, circle,
etc) ? Or maybe the shapes are defined by bitmaps (pixels with a value > some
threashold are "inside", everything else is outside) ?
Are the shapes concave ? Is self-intersection possible ? Are they connected
(equivalent to asking if there may be more than one S at a time) ?
What if there is more than one closest point ?
If edges intersect at sharp angles, is the intersection point eligible ?
(There are probably more geometrical questions than that -- I'm too lazy to
think of more.)
How fast do you want the search to be ?
How much data is required to define a typical shape (or groups of shapes) ?
Are you likely to ask for the answer with the same S (or Ss) but different P
often (so it may become worthwhile pre-processing S for faster lookup) ?
Are there any frequently-occuring special cases which could be identified and
handled specially (to save space or time) ?
And so on...
-- chris
Filip Larsen - 22 Oct 2006 13:24 GMT
rmacnak@gmail.com
> If I have Shape S and Point P. How do I find the point on the
> perimeter of S that is closest to P?
I haven't really tried to solve this problem, but it looks like the
Shape.getPathIterator() method and PathIterator class can be useful here
combined with some formulas for calculating point distance from the
curve segment types that PathIterator can return.
Regards,

Signature
Filip Larsen