
Ben A. answered 04/29/20
PhD student with 10+ years experience in Math, CS, and Logic
The classic formula for the area of a triangle is area = 1/2 * base * height. But when none of the sides are horizontal or vertical, this can be hard to use. Instead we have a fancy formula for finding the area of a triangle given any three points.
Suppose your three points are (x1,y1) (x2, y2) and (x3, y3)
Then the area is area = 1/2 * | x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2) |
Notice the | bars | on the outside that mean you should take the absolute value. The area has to be positive.
Why does this work? I won't give a proof, but here's the general idea.
What it's doing is finding three triangles whose areas are added together or subtracted from each other to get the same area as the big triangle we want. The trick is that these three triangles all have one side that is either horizontal or vertical, so we can use the classic formula for each of them separately.
The first triangle has area 1/2 * | x1 * (y2 - y3) |
The second triangle has area 1/2 * | x2 * (y3 - y1) |
The third triangle has area 1/2 * | x3 * (y1 - y2) |