How to divide a convex Polygon in Minimum rectangle and Triangle? - polygon

I Have a Convex Polygon that I want to divide into the Minimum Number of Rectangles and Triangles.
Is there any algorithm to divide it?

Related

Find the polygon area on a sphere bounded by points

I am trying to find the area of a polygon on a sphere. I have the azimuth and elevation angles (lat/lon). Is there an algorithm that will do this. If it were on a flat plane, I could approximate using a convex hull, but these points are occupying a significant portion of the sphere.

How to create a non-intersecting polygon in 3D containing n given points on a sphere?

I have the coordinates of n points on a sphere and I know they are all coplanar. How can I find the edges of the polygon which has the vertex the n given points?
OK, your problem is weird ordering.
Project all points onto any convenient plane - the simplest approach is using OXY, OXZ or OYZ plane (choose one that is not perpendicular to your plane) - in this case you just use (P[i].X. P[i].Y, 0) for P[i] point and sort projected 2D points by angle against the first point - it works because points on sphere arc form convex polygon. Then use this ordering as polygon vertex indexes.

Subdividing a general polygon in a number of small convex polygons

I have a polygon P made of N vertices. I need an algorithm that, given P, subdivide it in a certain number of convex polygons each using at most M vertices.
Ps.
P is a 2D polygon. Furthermore, i can use a polygon triangulation, but i am interested in algorithms that subdivide P into convex polygons having more than 3 vertices (and, as said above, at most M).
Quadtree methods would be my recommendation. Check those out.

Create polygon with equal angles and equal sides from large number of point on the plane

I have a set of points on the plane (300 000 points). How do I find a polygon with equal cosines of angles and equal sides where vertices of polygon are some of points? The more number of sides and more lengths of sides the better.

Calculate distance between two x/y coordinates?

I would like to calculate the distance between two x/y coordinates on the surface of a torus. So, this is a normal grid that has the property that its corners and sides are 'connected'. For example, on a grid of 500x500, the point at (499, 499) is adjacent to (0, 0) and the distance between e.g. (0,0) and (0,495) should then be 5.
Is there any good mathematical way of calculating this?
So you are looking for the Euclidean distance on the two-dimensional surface of a torus, I gather.
sqrt(min(|x1 - x2|, w - |x1 - x2|)^2 + min(|y1 - y2|, h - |y1 - y2|)^2)
where w and h are the width (x) and height (y) of the grid, respectively.
If/while the distance between x coordinates is larger than half of the grid X size, add grid X size to the smaller x coordinate.
Do the same for Y.
Then calculate the distance.
If your grid wraps around at the edges, there will be four distances between each coordinate (for 2 dimensions). I'm assuming you want to know the shortest distance.
Let's use a smaller grid, the numbers are a bit more manageable. Say the grid is 10x10. Let's also use just one dimension for simplicity (in which case there'll be just two distances), just as you have in your example. Say we have the points 0,2 and 0,6. The two distances between the points are d_1 = (6-2) = 4 and d_2 = (10-6) + 2 = 6, so in this case the shortest distance would be d_1.
In general, you can do the following:
For each coordinate:
subtract the smaller from the larger number
if the result is greater than half the width of the grid the shortest distance in this coordinate is the grid width minus the result
if the result is less than half the width of the grid, the shortest distance in this coordinate is the result
Then using Pythagoras' theorem, the shortest distance between the two points is the square root of the sum of the squares of the shortest distances in each direction. You can calculate the other three distances by calculating Pythagoras' theorem using the other combinations of distances in each direction.
As another poster has said, the shape formed when you wrap round at the edges (for a 2 dimensional grid) is a torus and I think the method I've used above is the same as the equation given but has the advantage that it can be extended to n-dimensions if required. Unfortunately there's not really an easy visualisation above 2 dimensions.
for points (x1,y1) and (x2,y2), you need to calculate 4 distances:
from (x1,y1) to (x2,y2)
from (x1,y1) to (x2, 500-y2)
from (x1,y1) to (500-x2, y2)
from (x1,y1) to (500-x2, 500-y2)
and then take the minimum of those.

Resources