Given 4 random points in 2D, how do I compute the area of the quadrilateral formed by the points?
I'm aware of formulae giving the area when I know the sides a,b,c,d and the diagonals p & q.
But how do I decide algorithmically which of the 6 connecting lines between the 4 points are sides and which are diagonals?



Quadrilateral from 4 random points
Here's a literal answer to your question: Sort the points, so that $a$ is has the leftmost $x$-coordinate, $b-a$ has the smallest argument (choosing the branch where arguments take values in $(-\pi,\pi]$), and $c-a$ has the largest argument. Take half the ($z$-coordinate of the) cross-product of $b-a$ with $c-a$ to get the area of the triangle $abc$. Add either $0$ or half the ($z$-coordinate of the) cross-product of $d-c$ and $d-b$, depending on which is bigger.


You might want to start by checking triples for collinearity and throwing out the internal points, to avoid ambiguity.


