|
-
Apr 10th, 2007, 12:49 PM
#1
Thread Starter
Hyperactive Member
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.
-
Apr 10th, 2007, 02:46 PM
#2
transcendental analytic
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.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 12th, 2007, 06:38 PM
#3
Thread Starter
Hyperactive Member
Re: Shrinking a Polygon
Is there an algorithm that will bring in each point in the correct direction?
-
Apr 13th, 2007, 04:22 AM
#4
transcendental analytic
Re: Shrinking a Polygon
just replace C with whatever point you want the polygon to shrink toward.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|