Arbitrary polygon scaling

I tried the Internet for several days, but could not find a good answer (or at least the one that made sense to me) to what seems to be a general question. How can I scale an arbitrary polygon? In particular, concave polygons. I need an algorithm that can handle concave (definitely) and self-intersecting (if possible) polygons. The obvious and simple algorithm that I used to process simple convex polygons calculates the center of gravity of the polygon, translating it to the origin, scaling all the vertices and translating the polygon back to its original location.

This approach does not work for many (or maybe all) concave polygons, since the centroid often goes beyond the polygon, so the zoom operation also leads to a translation, and I need to be able to scale the polygon "in place" without the final translation result.

Does anyone know of a method for scaling concave polygons? Or maybe a way to find a "visual center" that can be used as a frame of reference for a zoom operation?

Just to clarify, I work in 2D space, and I would like to scale my polygons using the "visual center" as a reference system. So maybe another way to ask a question: how to find the visual center of a concave and / or self-intersecting polygon?

Thank!

+5
source share
3 answers

The reason you cannot find a good answer is because you do not accurately meet your requirements. First, I explicitly define what you mean by "in place." What is kept constant?

Once you understand this, translate the constant point to the origin, scale the polygon, as usual, and move it back.

+1
source

I am not sure what the problem is.

Are you working in an affine space and are you looking for an affine transform to scale your polygon?

If I'm right, just write the transformation matrix:

And transform your matrix polygon

You can find the affine transformation matrix.

,


"", G = :

:
enter image description here

G , .

- , . ( )

G : G (x, y): ( x , y )

,

+4

, " ", . , . , , - / (, ) .

( ), (Clipper), Delphi, ++ #, .

+2

All Articles