-
Shrinking a Polygon
I have two arrays, one with X coordinates and one with Y coordinates, I also have the area calculated, how can I shrink the polygon a certain amount of distance? I tried think about this but its hard to come up with something because it depends on how many points are on the polygon.
-
Re: Shrinking a Polygon
Certain amount of distance? Do you mean the perimeter of the polygon should be reduced a certain distance by shrinking the polygon? If so then it should shrink proportional to the ratio between the remaining perimeter and the full perimeter. You may also want to specify toward what point it should shrink e.g. the centroid:
http://local.wasp.uwa.edu.au/~pbourk...etry/polyarea/
then given the old point P the new point Q can be calculated in vector algebra:
Q= (P-C)*R
i.e. Qx = (Px-Cx)*R and Qy = (Py-Cy)*R
where R = new perimeter / full perimeter
and new perimeter = full perimeter - amount of distance to reduce
C is the centroid or whatever point you want to the polygon to shrink toward.
The full perimeter can be calculated by summing the distance between each corner. The distance between two points is sqrt(dx^2 + dy^2) where dx is the difference in x component and dy the difference in y component.
-
Re: Shrinking a Polygon
Is there an algorithm that will bring in each point in the correct direction?
-
Re: Shrinking a Polygon
just replace C with whatever point you want the polygon to shrink toward.