Area of a triangle from coordinates

Prerequisites

Area of a triangle from coordinates

Introduction

• Finding the area of a triangle using it's base and height is easy.
• But sometimes the base isn't perpendicular to it's height.
• In these cases we can use a different method that relies only on the coordinates of the corners (vertices) of the triangle.
• If the 3 vertices are given as: (x1, y1), (x2, y2), (x3, y3)
• Then the equation of it's area is:
LaTeX formula:\left| \frac{ x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2) }{2} \right|

Proof

• Given a triangle:
• With vertices:
• a: 1, 1
• b: 9, 2
• c: 5, 5
• 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