Question: In my game I have 3 points that create a triangular plane similar to the image below but with uniform coordinates:

[![enter image description here](https://i.stack.imgur.com/gxR3e.png)](https://i.stack.imgur.com/gxR3e.png)

Each tringle is made of 3 points e.g.

P0 (x,y,z)

P1 (x,y,z)

P2 (x,y,z)

I also have the point:

P (x,y,z)

As shown in the diagram below, is is possible to tell if the plane created by P0, P1 & P2 passes through P?

[![enter image description here](https://i.stack.imgur.com/KUif9.png)](https://i.stack.imgur.com/KUif9.png)

I have looked online however all results do not seem to fit the problem in a programming orientated approach. Ideally i'd like to pass the coordinates to a function/equation and get a true/false result.

Thanks

Answer: 
Compute the volume $V$ of the [tetrahedron](https://en.wikipedia.org/wiki/Tetrahedron) formed by $P, P\_1, P\_2, P\_3$ by any formula you know. e.g.
$$V = \frac16 |(P\_1 - P)\cdot((P\_2 - P)\times(P\_3 - P))|
= \frac16\left\|\begin{matrix}
x\_1 - x & x\_2 - x & x\_3 - x\\
y\_1 - y & y\_2 - y & y\_3 - y\\
z\_1 - z & z\_2 - z & z\_3 - z\end{matrix}\right\|$$
The point $P$ falls into the plane if and only if $V$ is $0$.

Assume $P$ falls within the plane. 
If you need to further test whether $P$ is inside $\triangle\_{P\_1P\_2P\_3}$,
you can compute the area of the four triangles 
$\triangle\_{PP\_1P\_2}$, $\triangle\_{PP\_2P\_3}$, $\triangle\_{PP\_3P\_1}$ and $\triangle\_{P\_1P\_2P\_3}$ by any formula you know, e.g.

$$A\_{PP\_1P\_2} = \verb/Area/(\triangle\_{PP\_1P\_2}) = \frac12| (P\_1 - P)\times(P\_2 - P)|$$
Point $P$ will be on or within the triangle if and only if

$$A\_{PP\_1P\_2} + A\_{PP\_2P\_3} + A\_{PP\_3P\_1} = A\_{P\_1P\_2P\_3}$$
Here is, at a high level, what you need to do in your program:

1. Calculate the equation of the plane using the three points. You can use linear algebra i.e. matrices to do this.
2. Plug the point you're checking into the equation. If it satisfies the equation, it's in the plane, else it's not.

As a programmer, you'd need to be concerned about accuracy here. Computers can only solve things to finite precision, so just remember that when doing your calculations!

**EDIT:** As amd correctly points out- this calculates whether the point is in the same plane as the triangle. It doesn't tell you that the point is within the triangle itself.