Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Largest triangle from a set of points [duplicate]

Possible Duplicate:
How to find largest triangle in convex hull aside from brute force search

I have a set of random points from which i want to find the largest triangle by area who's verticies are each on one of those points.

So far I have figured out that the largest triangle's verticies will only lie on the outside points of the cloud of points (or the convex hull) so i have programmed a function to do just that (using Graham scan in nlogn time).

However that's where I'm stuck. The only way I can figure out how to find the largest triangle from these points is to use brute force at n^3 time which is still acceptable in an average case as the convex hull algorithm usually kicks out the vast majority of points. However in a worst case scenario where points are on a circle, this method would fail miserably.

Dose anyone know an algorithm to do this more efficiently?

Note: I know that CGAL has this algorithm there but they do not go into any details on how its done. I don't want to use libraries, i want to learn this and program it myself (and also allow me to tweak it to exactly the way i want it to operate, just like the graham scan in which other implementations pick up collinear points that i don't want).

like image 385
Faken Avatar asked Jun 17 '10 20:06

Faken


1 Answers

Don't know if this help, but if you choose two points from the convex hull and rotate all points of the hull so that the connecting line of the two points is parallel to the x-Axis, either the point with the maximum or the one with the minimum y-coordinate forms the triangle with the largest area together with the two points chosen first.

Of course once you have tested one point for all possible base lines, you can remove it from the list.

like image 167
Landei Avatar answered Oct 27 '22 21:10

Landei