I have coordinate points for a irregular polygon like (x1,y1) ...(x1,y1). I'm able to calculate area of polygon using the coordinates. How can i expand or shrink the polygon area by using coordinates.?
Asked
Active
Viewed 5,169 times
1 Answers
5
Simply multiply each coordinate by a fixed value to scale around the origin.
for each vertex i
result[i].x = input[i].x * scale
result[i].y = input[i].y * scale
If you want to scale around a different point:
translate to origin (subtract the scaling center)
scale by the correct amount (multiply by a constant)
translate from origin (add the scaling center)
To scale the area by a factor of four, you need to scale the distances by a factor of two. So, if your scale is defined in terms of area, don't forget to convert to linear measure:
scale = sqrt area_scale
in case you want to scale the volume:
scale = volume_scale ^ (1/3)

John Dvorak
- 26,799
- 13
- 69
- 83
-
1Given the discussion at http://stackoverflow.com/questions/1109536/an-algorithm-for-inflating-deflating-offsetting-buffering-polygons, I'm commenting to point out that you need to be careful about the value of `scale` . It's different for shrinking the area vs. shrinking the distance (radial) between the original and adjusted polygons. – Carl Witthoft Aug 07 '13 at 17:20
-
@CarlWitthoft thanks, I missed that part of the specification. – John Dvorak Aug 07 '13 at 17:27
-
not sure what discussion you have in mind, however. – John Dvorak Aug 07 '13 at 17:31
-
Well, there's a couple things. The OP here didn't ask a very clear question, so your answer certainly covers some simple cases, and you get a new polygon that is similar (in the geometry definition) to the original. However, for polygons which are not "star-shaped" (topology), the new polygon cannot fit in the interior of the original. Polygon buffering or skeletonizing shrinks nonlinearly. I don't think that's what the OP wanted here, but am not sure. – Carl Witthoft Aug 07 '13 at 18:06
-
I understood the question as a simple scaling, but yes - it is ambiguous. I'm voting to close as unclear. – John Dvorak Aug 07 '13 at 18:10