I'm having school project in which I have to implement tetrahedron. I have to overload the >> , << , == to check if a 3d(x,y,z) point is in,on,outside of the tetrahedron, which is represented by 3d points as well. How can I do that (the bold text, I don't know the theory for that)?
Asked
Active
Viewed 175 times
0
-
I'm struggling with understanding the theory. – Пламен Дамянов May 30 '20 at 08:10
-
You now just check if a point P is on the other side of the plane. The normal of each plane is pointing away from the center of the tetrahedron. So you just have to test against 4 planes. Your plane equation looks like this: a*x+b*y+c*z+d=0 Just fill in the point values (x y z). If the sign of the result is >0 the point is of the same side as the normal, result == 0, point lies in the plane, and in your case you want the third option: <0 means it is on the backside of the plane. If this is fulfilled for all 4 planes, your point lies inside the tetrahedron. – Пламен Дамянов May 30 '20 at 08:11
-
a*x+b*y+c*z+d=0, so if I'm correct in this equation (x,y,z) stand for the coordinates for the point I'm checking. What does a,b,c,d stand for? – Пламен Дамянов May 30 '20 at 08:14
-
If you are interested in the mathematical basics https://math.stackexchange.com/ might be a better place to ask. I don't think I'm versed enough to explain any of this, just found the duplicate. Maybe the [second answer](https://stackoverflow.com/a/25180294/5105949) is clearer. Though it's in a C# not C++ that algorithm is the same. – Lukas-T May 30 '20 at 08:20