How to calculate the area of a 3D triangle?

If your 3 points are A, B, C then you may use directly the (half) cross product formula : $$S=\dfrac{|\mathbf{AB}\times\mathbf{AC}|}2=\dfrac{|\mathbf{AB}||\mathbf{AC}||\sin(\theta)|}2 $$ that is (see the Wikipedia link to get the cross-product in $\mathbb{R}^3$) : $$S=\frac 12 \sqrt{(y_{AB}\cdot z_{AC}-z_{AB}\cdot y_{AC})^2+(z_{AB}\cdot x_{AC}-x_{AB}\cdot z_{AC})^2+(x_{AB}\cdot y_{AC}-y_{AB}\cdot x_{AC})^2}$$ if $\mathbf{AB}=(x_{AB},y_{AB},z_{AB})$ and $\mathbf{AC}=(x_{AC},y_{AC},z_{AC})$


Say you have 3 points $\mathbf{A, B, C}$. Find the angle $\theta$ between $\mathbf{AB}$ and $\mathbf{AC}$ using dot product (i.e. $\mathbf{AB}\cdot\mathbf{AC}=|\mathbf{AB}||\mathbf{AC}|\cos\theta$) and then you can find the area of the triangle using $$ A=\frac{1}{2}|\mathbf{AB}||\mathbf{AC}|\sin\theta $$


Probably one of the best ways (and possibly least computationally intensive ways) to approach this problem is with vectors. In this case we have three points, I will keep them as arbitrary variables for better reproducibility.

$$P_1(a_1,a_2,a_3); \ \ \ P_2(b_1,b_2,b_3); \ \ \ P_3(c_1,c_2,c_3)$$

These three points can be used to create two vectors which share the same initial point. It does not matter in what combination we choose the points, so long as we create two vectors with the same initial point to then calculate their normal (orthogonal) vector using the cross product. Once we have the orthogonal, we can get its magnitude which will equate to 2 times the area of the said triangle. (The magnitude of the orthogonal will give us the area of a parallelogram sharing the same adjacent sides, therefore we will half this area in the end to get the area of the triangle).

To create the vectors from a pair of points, you do the following:

$$ \vec{P_1P_2} = <b_1-a_1,b_2-a_2,b_3-a_3> = <x_1, y_1, z_1>$$ $$ \vec{P_1P_3} = <c_1-a_1,c_2-a_2,c_3-a_3> = <x_2,y_2,z_2>$$

Here is a basic picture of what we will be doing:

We will get the area of this parallelogram and then half it

Once you have both vectors you can calculate their orthogonal vector by taking their cross product, you do it as follows:

$$\vec{u} = \vec{P_1P_2} \times \vec{P_1P_3}$$ $$\vec{u} = \begin{vmatrix} \mathbf i & \mathbf j & \mathbf k \\ x_1 & y_1 & z_1 \\ x_2 & y_2 & z_2 \\ \end{vmatrix}\\ $$

$$\vec{u} = \begin{vmatrix} y_1 & z_1\\ y_2 & z_2 \end{vmatrix}\mathbf i - \begin{vmatrix} x_1 & z_1\\ x_2 & z_2 \end{vmatrix}\mathbf j + \begin{vmatrix} x_1 & y_1\\ x_2 & y_2 \end{vmatrix}\mathbf k $$

This boils down to:

$$\vec{u} = (y_1z_2-y_2z_1)\mathbf i-(x_1z_2-x_2z_1)\mathbf j+(x_1y_2-x_2y_1)\mathbf k\\= \ <y_1z_2-y_2z_1,\ x_1z_2-x_2z_1,\ x_1y_2-x_2y_1> \\= \ <x_3,y_3,z_3>$$

Once you have the orthogonal vector from the cross product, we calculate its magnitude:

$$|\vec{u}| = \sqrt{(x_3)^2+(y_3)^2+(z_3)^2} = \mathbf{Area\ of\ Parallelogram}$$

Finally we are left with the area of a parallelogram composed of two of our triangles. At this point we half the magnitude, and we will have the desired result.

$$\frac{|\vec{u}|}{2} = \mathbf{Area\ of\ Triangle}$$


Heron's formula is easiest as it "requires no arbitrary choice of side as base or vertex as origin, contrary to other formulas for the area of a triangle:" $$A = \sqrt{s(s-a)(s-b)(s-c)}$$ where $s=p/2$ is half of the perimeter $p=a+b+c$ (called the semiperimeter of the triangle). The triangle side lengths can be obtained via vector norm of relative positions: $$a=\|\vec{r}_1-\vec{r}_2\|$$ $$b=\|\vec{r}_2-\vec{r}_3\|$$ $$c=\|\vec{r}_3-\vec{r}_1\|$$