I want to fit images in selected polygons.
To do so, I get the polygon and then I like to get the smallest width and the smallest height of the polygon.
With this rectangle information, I create a plane and place one image on the plane.
The plane is then placed using the normal of the polygon.
Question: is there an easy way to get the smallest width and height of a polygon.
See for example this picture
Here how I calculate the width and height.
p = obj.GetPolygon(index) a = allp[p.a] b = allp[p.b] c = allp[p.c] d = allp[p.d] w1 = (a - d).GetLength() w2 = (b - c).GetLength() h1 = (a - b).GetLength() h2 = (d - c).GetLength() width = w1 if (w2 < w1): width = w2 height = h1 if (h2 < h1): height = h2
This code does not seem correct, because the Coordinate Manager show a different size.
Also, the sequence of the points (a,b,c,d) is not always the same.
Sometimes it starts in the lower left corner and sometime in the upper right corner.