Area of a Triangle in 3-D

Given three vertices in 3-D space — (x1, y1, z1), (x2, y2, z2), and (x3, y3, z3) — there are two common approaches to computing the area of the triangle they define.


Heron's Formula

First, compute the lengths of the three sides:

Side lengths a = √[ (x1 − x2)2 + (y1 − y2)2 + (z1 − z2)2 ]
b = √[ (x1 − x3)2 + (y1 − y3)2 + (z1 − z3)2 ]
c = √[ (x2 − x3)2 + (y2 − y3)2 + (z2 − z3)2 ]

Then compute the semiperimeter:

Semiperimeter s = (a + b + c) / 2

And plug everything into Heron's formula:

Area (Heron) Area = √[ s · (s − a) · (s − b) · (s − c) ]

Considerations

  • If the triangle is a very thin sliver (nearly degenerate), Heron's formula can suffer from floating-point cancellation errors. A numerically stable variant exists: sort the sides so that abc, then use
    Area = ¼ √[ (a+(b+c)) · (c−(a−b)) · (c+(a−b)) · (a+(b−c)) ]
  • This approach requires four square roots — one for each side and one in the final formula. If you need to compute thousands of triangle areas and have no other use for the side lengths, the cross-product method below is more efficient.

Cross-Product Method

The area of a triangle is half the magnitude of the cross product of two edge vectors. If we define the vectors u and v as two edges sharing a common vertex:

Edge vectors u = (x2 − x1,  y2 − y1,  z2 − z1)
v = (x3 − x1,  y3 − y1,  z3 − z1)

The cross product u × v has three components:

Cross product components nx = uy · vz − uz · vy
ny = uz · vx − ux · vz
nz = ux · vy − uy · vx

And the area is:

Area (Cross Product) Area = √( nx2 + ny2 + nz2 ) / 2

Expanded Form

Substituting the vertex coordinates directly, the formula expands to a single expression. This is long but easy for a computer, and it requires only one square root:

Full expansion in vertex coordinates nx = (y2−y1)(z3−z1) − (z2−z1)(y3−y1)
ny = (z2−z1)(x3−x1) − (x2−x1)(z3−z1)
nz = (x2−x1)(y3−y1) − (y2−y1)(x3−x1)

Area = √( nx2 + ny2 + nz2 ) / 2

This is the approach to prefer when performance matters — it involves only multiplications, additions, subtractions, and a single square root. It is also numerically stable for thin slivers, unlike the naive form of Heron's formula.