Point Vs Triangle ?

E02262cf1f3533b39835df6c8928b254
0
ebikhan 101 Nov 24, 2005 at 04:11

I want to determine whether a point lies inside a triangle or not. and If no, then determine to which side of triangle it lies, to back side or front side. I have followed many papers on internet.

I only had to create plane’s equation:-
Ax + By + Cz + D = 0.

Determine A,B,C,D and put the point into that equation. If its zero it lies
inside the plane.If > 0 then on 1 side(u can call it front side) and If < 0 then on the other side(say back side).

I did but I am facing problem.

Assume A(0, 0, 0), B(10, 0, 0), C(20, 10, 0). I get all A,B,C,D zeros.
I cant proceed onwards.

What I be doing wrong. Plus on another fast and good solution. Please do solve with this example.

Thanx alot for any help.

2 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Nov 24, 2005 at 07:10

You shouldn’t get all the values be zero in that case. Calculate [A,B,C] as the normal of the plane. That is, if the three points of the triangle are P1, P2, P3, then let [A,B,C] be the vector cross(P2 - P1, P3 - P1). Then take D = -[A,B,C] dot P1 (which is simply the solution of [A,B,C] dot P1 + D = 0.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 24, 2005 at 12:02

Maybe you need to aproach this from another angle to understand what’s going on.
Consider a normal in space. You may argue that it defines a plane in space. But you may move the normal in space. At each possible position you could move the normal to, it defines a plane of it’s own. Hence you need an additional point in space, where you attach the normal.

P : n dot (p - p0) = 0

This let’s you define the following plane equation. p is an arbitrary point in space and p0 an point on the plane. p0 - p therefore is a vector from one point on the plane to the point p. The reason why this works is, because the dot product between p - p0 and the normal actually projects p - p0 onto the normal (that is it gives the length of that projected vector). If that length is zero, the point must obviously be on the plane.

If you multiply this out you get :

nx * px + ny * py + nz * pz + d = 0, where d = -nx * p0x - ny * p0y - nz * p0z

Of course this is the plane equation you gave. If you sketch this out on paper it should all become clearer. The rest should work as Reedbeta mentioned. Just make sure you renormalize your n vector after you got it out of the cross product. Allthough that shouldn’t matter if you just want to know if a point is in front or behind the plane. If you need the exact distance to the plane renormalization is required though.