java geometry

R

rmacnak

If I have Shape S and Point P. How do I find the point on the
perimeter of S that is closest to P?
 
C

Chris Uppal

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
 
F

Filip Larsen

(e-mail address removed)
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top