I recently ran across an elegant equation for the area of a triangle in the complex plane with vertices at z1, z2, and z3. [1].
This formula gives the signed area: the area is positive if the points are given in countclockwise order and negative otherwise.
I’ll illustrate the formula with a little Python code. Let’s generate a random triangle.
import numpy as np np.random.seed(20221204) r = 100*np.random.random(6) z1 = r[0] + 1j*r[1] z2 = r[2] + 1j*r[3] z3 = r[4] + 1j*r[5]
Here’s what our triangle looks like plotted.
Now let’s calculate the area using the formula above and using Heron’s formula.
def area_det(z1, z2, z3): det = 0 det += z2*z3.conjugate() - z3*z2.conjugate() det -= z1*z3.conjugate() - z3*z1.conjugate() det += z1*z2.conjugate() - z2*z1.conjugate() return 0.25j*det def area_heron(z1, z2, z3): a = abs(z1-z2) b = abs(z2-z3) c = abs(z3-z1) s = 0.5*(a + b + c) return np.sqrt(s*(s-a)*(s-b)*(s-c)) print(area_heron(z1, z2, z3)) print(area_det(z1, z2, z3))
This prints -209.728 and 209.728. The determinate gives a negative area because it was given the points in clockwise order.
[1] Philip J. Davis. Triangle Formulas in the Complex Plane. Mathematics of Computation. January 1964.
This technique is easy to teach to high school geometry students that have no knowledge of complex numbers or determinants.
A little analytical geometry is all.
Fun fact for them.
It looks like the Shoelace method gets the same result with half the work:
def shoelace(z1, z2, z3):
# https://en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
total = A*B.conjugate() + B*C.conjugate() + C*A.conjugate()
return total.imag / -2