does a point belong to this face ?

Started by
3 comments, last by PoisKaille 21 years, 7 months ago
Hi, I want to know if a given point is part of a face (triangle) in a 3d world. I know the coordinates of the 3 points of the face (P1,P2,P3) and the coordinate of the point i want to test (M).
Advertisement
http://www.faqs.org/faqs/graphics/algorithms-faq/

Assuming the point is in the same plane as the polygon:

2.03: How do I find if a point lies within a polygon?


Otherwise your best bet is to test whether a ray which passes through the point also hits the polygon:

5.06: How do I determine the intersection between a ray and a triangle?


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Be warned about floating-point rounding errors, they might mess everything up if you''re not careful.

- JQ
Full Speed Games. Period.
~phil
That answer you got was completely off. Here's how to do it. This returns 0 if the point is on the plane, <>0 for in front or behind:

function pointonplane(x.f,y.f,z.f,nx.f,ny.f,nz.f,d.f)
Return (nx*x+ny*y+nz*z+d)
end function

[edited by - JoshKlint on September 13, 2002 7:02:16 PM]
JoshKlint:

Umm - read the posters message, and re-read my reply. So what part of my reply is "completely off" ?.

In fact your reply is "completely off" with regard to the question since it only confirms whether a point is in the **infinite** plane. PoisKaille asked how to determine whether the point was in the the **triangle** (i.e. bounded plane).



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement