# How to enlarge a 2D polygon (conex, nonconvex)

Discussion in 'C Programming' started by Shamli, Oct 10, 2003.

1. ### ShamliGuest

I am looking for an algorithm that enlarge a 2D polygon.
cheers,

Shamli, Oct 10, 2003

2. ### Rafal 'Raf256' MajGuest

news:

> I am looking for an algorithm that enlarge a 2D polygon.
> cheers,

Is polygon is a set of 2D points, how about multiplying all of them by some
value ?

x *= zoom;
y *= zoom;

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~l-.~~~~~~~~~~~~~~~~~~~
GG-1175498 ____| ]____,
Rafal 'Raf256' Maj X-( * )
Rafal(at)Raf256(dot)com ,"----------"

Rafal 'Raf256' Maj, Oct 10, 2003

3. ### ShamliGuest

yes the polygon is a set of 2D points;
No this will not work. by multiplying we are just moving the polygon.

"Rafal 'Raf256' Maj" <> wrote in message news:<Xns941195E9139Eraf256com@213.180.128.20>...
> news:
>
> > I am looking for an algorithm that enlarge a 2D polygon.
> > cheers,

>
> Is polygon is a set of 2D points, how about multiplying all of them by some
> value ?
>
> x *= zoom;
> y *= zoom;

Shamli, Oct 11, 2003
4. ### Arthur J. O'DwyerGuest

On Sat, 11 Oct 2003, Shamli wrote:
>

[re-arranged for clarity]

A: Because it's annoying as hell.
Q: Why shouldn't I top-post?

> "Rafal 'Raf256' Maj" <> wrote in message news:<Xns941195E9139Eraf256com@213.180.128.20>...
> > news:
> >
> > > I am looking for an algorithm that enlarge a 2D polygon.
> > > cheers,

> >
> > Is polygon is a set of 2D points, how about multiplying all of them by some
> > value ?
> >
> > x *= zoom;
> > y *= zoom;

>
> yes the polygon is a set of 2D points;
> No this will not work. by multiplying we are just moving the polygon.

No, you're not. You're scaling it by the constant 'zoom'.
Try it and see. Alternately, you can keep the centroid of
the polygon in the same place by first scaling it, and *then*
translating ("moving") it back to the "right" place by adding
a second constant.

Take this to comp.programming (followups set).

-Arthur

Arthur J. O'Dwyer, Oct 11, 2003
5. ### Rafal 'Raf256' MajGuest

news:

> yes the polygon is a set of 2D points;
> No this will not work. by multiplying we are just moving the polygon.

Wrong,
by multiplaying You *are* zooming (and maybe also moving - is object is not
centered before).

To just move we must add x+= y+=

Hm maybe I can write smale example for You, contact mu on priv (I'm adding
to my whitelist)

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~l-.~~~~~~~~~~~~~~~~~~~
GG-1175498 ____| ]____,
Rafal 'Raf256' Maj X-( * )
Rafal(at)Raf256(dot)com ,"----------"

Rafal 'Raf256' Maj, Oct 11, 2003