This question already has an answer here:

I have a set of points

Pts[a_,b_,c_]:={{a, b}, {b, a}, {c, a}, {a, c}, {b, c}, {c, b}}

which define a convex polygon and I would like to find its area. There is a simple method but it requires listing the points in counterclockwise order, but I don't know (in general) how to put them in this order. (Leaving them in their given order produces a self-intersecting polygon with a too-small area.) What can I do here?

I could imagine a sorting routine of some kind (find the middle and order by $\theta$? but probably there could be issues) or maybe there is some built-in method. In any case I certainly don't want to iterate over possible orders, since those grow very quickly and clearly it isn't the right thing to do.

An answer addressing my special case is sufficient, but I would be interested in a general method that works with an arbitrary set of points defining a convex polygon.


marked as duplicate by Kuba, Yves Klett, ciao, m_goldberg, Oleksandr R. Apr 24 '14 at 9:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ answer and related $\endgroup$ – Kuba Mar 24 '14 at 20:23
  • $\begingroup$ @Kuba: I can't get ConvexHull to give sensible results. ConvexHull[{{4, 3}, {3, 4}, {2, 4}, {4, 2}, {3, 2}, {2, 3}}] gives {4, 1, 2, 3, 6, 5}. $\endgroup$ – Charles Mar 24 '14 at 20:33
  • $\begingroup$ This is the order. $\endgroup$ – Kuba Mar 24 '14 at 20:35
  • $\begingroup$ You can try using FindCurvePath to get your polygon points in order... no guarantees of it working for all input though (in fact, it might fail for anything other than small/toy problems). BTW, this is a duplicate: mathematica.stackexchange.com/q/9406/5 $\endgroup$ – rm -rf Mar 24 '14 at 20:37
  • 1
    $\begingroup$ If your polygon is known to be convex then ordering by angle relative to the mean of the vertices will also work. $\endgroup$ – Rahul Mar 24 '14 at 22:55

Ugly + undocumented solution:

make[pts_] := PolygonArea[With[{order = ConvexHull[pts]},
  Append[pts[[order]], pts[[order[[1]]]]]]]
  • 2
    $\begingroup$ Please add a Graphics of the Convex Hull calculated in this way for the example given by the OP in his comments pts={{4, 3}, {3, 4}, {2, 4}, {4, 2}, {3, 2}, {2, 3}} $\endgroup$ – Dr. belisarius Mar 25 '14 at 7:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.