How to Determine if a Point is in a Triangle Plane
First off we have a triangle below with a point in it.
We all see that the point is in the plane but how do we make the computer realize this?
At this point we only use the x and y coordinates to determine if the point is in the plane.
This could be called the XY plane.
But how to calculate the length of the sides a, b, c?
To calculate the distance between two point you use the formula
So to determine the length of side a it would go like this
and side b
And now how to finally determine the angle A we use the formula
We have the length of all the sides in the sub triangle so we just put them in there.
So now we have the angle of the first sub triangle and we just repeat the calculations for all the sub triangles.
Now you may ask, but I wanna test in 3D so what about the z axis? Look at the picture below. It is the same triangle as before but now where looking at it from above.
We use the same calculations but now we put in the z coordinate instead of the y coordinate.
This could be called the XZ plane and calculate it just like the XY plane.
The same goes for the ZY plane that could look like this looking at the triangle from the side as you may suspect we use the z and y coordinates to make up our triangle.
If you calculate all of the angles in each plane and if the sum off the angles in each plane is 360 degrees then the point is actually in the triangle plane.
I beleive the author's aim is to determine if the point is in "triangle's plane", while it can be both "inside and outside of the triangle". In this case, I don't think there is a need to use such time-consuming operations as: sqr() sqrt() and cos(), which are actually used.
Using the notation used in the article, let me introduce the slightly different method, that is used in analytical geometry. It is pretty simple and deals only with some multiplications: Say, the triangle is given by the three points:
A ( xA, yA, zA) B ( xB, yB, zB) C ( xC, yC, zC)
and we want to determine if the point
M ( x, y, z)
is inside that triangle.
It is necessary (and more than enough) for the three vectors "MA", "MB" and "MC" to be co-planar. That is - one of them is a certain linear combination of others.
From analytical geometry we know, that 3 vectors are co-planar if:
|x-xA y-yA z-zA| |x-xB y-yB z-zB| = 0 |x-xC y-yC z-zC|
(that is: det((MA)...,(MB)...,(MC)...)=0)
But to calculate a 3x3 determinant very few calculations are needed! Something like 12 multiplications and 6 sumations. After that we have to calculate the deviation of the result from 0 (like in the article we calculate the deviation of the total angle from 360 deg) to find out if the point is inside the triangle plane!
That's all about it! So instead of calculating the unnecessary information about triangles, sides, lengths, angle sizes, etc for 4 triangles, we only calculate a 3x3 determinant!
This can also be used to determine if the point is "inside" the triangle and so on...