In comp.graphics.algorithms message <f5d7ded9-97d6-449c-8dc2-d52cf54722f
Post by BTIS JeffI'm looking for a way to get the coordinates of vertices of a polygon
offset x pixels within a known polygon. This seems to be a non-
trivial problem, but I thought of a trick - What if I have the original
polygon drawn by Windows with a thick line, the inside edges of that
thick line will then describe a new polygon. Does anyone know a way
to get the coordinates of the inside edges of this thickly drawn
polygon. I usually work in VB, VB.NET, or C#, but solution in any
language would be welcome.
Firstly, you need to think what "x pixels from a line" means if the line
is not parallel to an axis.
Secondly, there are at least four types of polygon :
self-crossing,
concave in places,
ordinary,
nearly round.
I guess that yours will not be the first case, probably not the second,
and that the third and fourth are not significantly different.
I assume, them, that you have an ordered set of coordinates for the
original vertices, and an offset in the same units.
I would, for each original side, find its middle, find a parallel line
at distance x inside, and calculate the intersections of each adjacent
pair of inner lines. QED.
If any corner has an internal angle very near 180 degrees, the solution
will be ill-conditioned.
For a sanity check, verify that the distances between each pair of inner
and outer vertices are near enough as expected.
--
(c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME.
Merlyn Web Site < > - FAQish topics, acronyms, & links.