Thursday 18 July 2024

Area of Triangle Using Matrices and Determinants

I watched an interesting YouTube video explaining how to use matrices and determinants to find the area of a triangle given its vertices. Of course, one could use the distance formula to find the lengths of the sides and then use Heron's formula to find the area but this method is far quicker as we'll see.

The first example used in the video involved the points (1,1), (4,1) and (4,5). These coordinates are used to form a 3 x 3 matrix with the x coordinates forming the first column, the y coordinates forming the second column, and the third column consisting of three 1's. The result is as shown below:$$ \begin{bmatrix} 1 & 1 & 1 \\ 4 & 1 & 1\\ 4 & 5 & 1 \end{bmatrix} $$The determinant of this matrix is 12 and the area of the triangle is simply half the value of the determinant, namely 6. The coordinates were chosen by the author of the video so that the the triangle formed by the vertices is right-angled and its area quickly calculated. See Figure 1.


Figure 1: f = 3 units and g = 4 units
and so area is  3 x 4 / 2 = 6 square units

Here is a permalink to a SageMath algorithm that will calculate the area form the coordinates of the input vertices. The second example in the video involved the vertices (2, 3), (5, 7) and (10, -5). This produces the following matrix:
$$ \begin{bmatrix} 2 & 3 & 1 \\ 5 & 7 & 1\\ 10 & -5 & 1 \end{bmatrix} $$This matrix has a determinant of -56 and we take half of its absolute value to calculate the area of the triangle to be 28 square units. See Figure 2.


Figure 2

The video goes through the process of finding the lengths of f, g and h using the Pythagorean theorem and then using Heron's formula to find the area. This is done to confirm that matrix/determinant method actually works so I won't reproduce that here. Suffice to say that once the matrix M is constructed, we can say that:$$\text{Area of Triangle }=\frac{1}{2} \times \text{ det } |M|$$This got me thinking about quadrilaterals and whether this method could be extended to find the area of quadrilaterals but it doesn't appear to. The quadrilateral would need to be broken up into two triangles and the area of each calculated using the matrix/determinant method.

No comments:

Post a Comment