Results 1 to 4 of 4

Thread: Shrinking a Polygon

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    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.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    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.

  3. #3

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Shrinking a Polygon

    Is there an algorithm that will bring in each point in the correct direction?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    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
  •  



Click Here to Expand Forum to Full Width