I need some help on this, it is due by 11 PM tonight and I'm not quite sure where to go.

In a C++ program, we are supposed to take in four data points of a quadrilateral (in order, so no jumping across the figure) and find the area in three different ways:

The first way is straightforward and does not have any issues associated with it.

The second and third way do have issues though. With the second way we are supposed to split up the quadrilateral into two triangles between the first inputted and third inputted vertices. With the third way we are supposed to split up the quadrilateral into two triangles between the second and fourth vertices.

When working with a convex quadrilateral (when there are no interior angles > 180 degrees), there is no issue. However, whenever there is a concave one, there will be one diagonal that does not actually bisect or intersect the figure at all:

The red line is the line between the first and third points, and the green is between the second and fourth. In this instance, the area from the sum of the two triangles for the 2nd and 4th one will be fine, but the line between the 1st and 3rd vertices will not work out.

This leads to incorrect area on concave figures. Not only does this make my calculated areas incorrect at times; but I also need to figure out whether the figure is concave or convex, and the way I did that before was that I halfed the quad into two triangles and used the law of cosines.

Could anyone help me find a tangible solution to this issue? I can provide my code if needed. I never tested a concave figure until I finished the test code--and found this issue just an hour or two ago.

In a concave quadrilateral one and only one of the internal angles is greater than 180°. The triangle containing this area needs to be treated as negative. When you sum the areas of the two triangles the total area of the quadrilateral will be correct.