On Tuesday, November 26, 2002, at 08:19  AM, Ted Hill wrote:
I forgot to mention that the GeneralPath that I want to
expand/contract is a
simple closed shape.

Does anyone know of an algorithm that can be used to 'expand' or
'contract'
a general path?
One thing I have used in the past to expand simple polygons is to:

calculate the "center" of the shape
foreach point p in polygon
   shift p along the line it shares with the center
   by an amount proportional to its distance from the center

This works okay for regular (or nearly regular) polygons.  A naive way
to calculate the center is to take the center of the bounding box.  As
you might expect, you get weird results if the "center" is not near the
visual center of the shape, which is pretty common with triangles using
the naive approach.  A better method for finding the center might be to
calculate the angle bisectors for each point and pick something close
to their intersection.

This method is not recommended for concave polygons.

HTH,
Rhett
=====================================================
| Rhett Sutphin
| Research Assistant (Software)
| Coordinated Laboratory for Computational Genomics
|   and the Center for Macular Degeneration
| University of Iowa - Iowa City, IA 52242 - USA
| 4111 MEBRF - email: [EMAIL PROTECTED]
=====================================================

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to