On Friday 31 August 2007 6:17 pm, Peter K. Stys wrote:
> Can anyone point me to an algorithm (with source preferably, C is
> fine) that "insets" a polygon (defined by a set of vertices as x,y
> coordinates). By inset I mean "shrink" towards its "center" (or
> expand if the dx,dy params are negative).
> Thanks,
> Peter.
Would something like this work?
f is your scale factor
Pick any new point, Px, Py
new x1 = Px + (Px - x1)*f
new y1 = Py + (Py - y1)*f
etc.
If you can define the "center" of your polygon and choose that point as your
new point, the polygon should appear to shrink in on itself. If the point is
somewhere else, the polygon will move, but shrink. I think the visual center
will be a point half way between the points (smallest x value, smallest y
value) and (largest x value, largest y value) from your list of vertices.
This is off the top of my head and entirely untested.
Don
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|