FriconiX
Free collection of beautiful vector icons for your web pages.

# How to check if four points are coplanar

## Introduction

The aim of this article is to check if four points are coplanar, i.e. they lie on the same plane. Let’s consider four points $$P_1$$, $$P_2$$, $$P_3$$ and $$P_4$$ defined in $$\mathbb{R}^3$$. This question may be reformulated as “is the point $$P_4$$ belongs to the plane defined by points $$P_1$$, $$P_2$$ and $$P_3$$“.

## Proof

First, let’s compute the normal vector to the plane defined by points $$P_1$$, $$P_2$$ and $$P_3$$:

$$\vec{n_1}=\vec{P_1P_2} \times \vec{P_1P_3}$$

Let’s now compute the normal vector to the plane defined by points $$P_1$$, $$P_2$$ and $$P_4$$:

$$\vec{n_2}=\vec{P_1P_2} \times \vec{P_1P_4}$$

If the points lie on the same plane, $$\vec{n_1}$$ and $$\vec{n_2}$$ are colinear and this can be check thanks to the cross product with this relation:

$$\vec{n_1} \times \vec{n_2} =0$$

This can be rewriten:

$$(\vec{P_1P_2} \times \vec{P_1P_3}) \times (\vec{P_1P_3} \times \vec{P_1P_4}) = 0$$

The previous equation can be simplified, and we can prove that the point $$P_4$$ belongs to the plane if :

$$\det ( \vec{P_1P_2} , \: \vec{P_1P_3} , \:\vec{P_1P_4} ) = 0$$

Proof (references here or here ):

\begin{align} (\vec{u} \times \vec{v}) \times (\vec{u} \times \vec{w}) &= ( (\vec{u} \times \vec{v}) \cdot \vec{w}) \vec{v} - ((\vec{u} \times \vec{v}) \cdot \vec{v}) \vec{w} \\ (\vec{u} \times \vec{v}) \times (\vec{u} \times \vec{w}) &= ( (\vec{u} \times \vec{v}) \cdot \vec{w}) \vec{v} \\ (\vec{u} \times \vec{v}) \times (\vec{u} \times \vec{w}) &= \det ( \vec{u} , \vec{v} , \vec{w} ) \vec{v} \end{align}

## Conclusion

The four points are coplanar if, and only if:

$$\det( \: \vec{P_1P_2} \: , \: \vec{P_1P_3} \: , \: \vec{P_1P_4} \: ) = 0$$

## Matlab source code

close all;
clear all;

%% 3 points for the plan
P1=[0;0;0];
P2=[1;0;1];
P3=[0;1;1];

%% Point to check
% Belong
P4=[2;2;4];
% Do not belong
%P4=[2;2;-2];

%% Display points and plane
plot3(0,0,0);
hold on;
grid on;
axis on;
patch ( [P1(1), P2(1), P4(1), P3(1)], [P1(2), P2(2), P4(2), P3(2)], [P1(3), P2(3), P4(3), P3(3)], 'red' );
plot3 (P1(1), P1(2), P1(3), '.', 'MarkerSize', 50);
plot3 (P2(1), P2(2), P2(3), '.', 'MarkerSize', 50);
plot3 (P3(1), P3(2), P3(3), '.', 'MarkerSize', 50);
plot3 (P4(1), P4(2), P4(3), '.', 'MarkerSize', 50);

%% Method 1: cross product
C = cross (cross(P2-P1, P3-P1), cross(P2-P1, P4-P1));
if (any(C))
disp('P4 does not belong to the plane (cross product)');
else
disp('P4 belongs to the plane (cross product)');
end;

%% Method 2: determinant
D = det( [P2-P1, P3-P1, P4-P1]);
if (any(D))
disp('P4 does not belong to the plane (determinant)');
else
disp('P4 belongs to the plane (determinant)');
end;