Proof
- Given a triangle:
- With vertices:
- First we extend each vertex down to the x-axis:
- This creates 3 trapaziums:
- The area of the triangle can then be expressed in terms of these trapeziums:
- The area of a trapezium is:
- The area of each of our trapeziums is:
- Plugging these into our area equation, we get:
- This simplifies to:
- Finally, the area must be positive, so we take the absolute value:
Code (Python)
triangle = [[1, 1], [8, 0], [6, 6]]
area = triangle[0][0] * (triangle[1][1] - triangle[2][1]) \
+ triangle[1][0] * (triangle[2][1] - triangle[0][1]) \
+ triangle[2][0] * (triangle[0][1] - triangle[1][1])
area /= 2
area = abs(area)
print(area) # prints 20.0