Advertisement

Point in a triangle in 3d!

Started by October 29, 2002 10:02 AM
7 comments, last by RiBa 22 years, 3 months ago
Hi, Can somebody show me a way to determine if a point lies in a triangle or not, in 3D? I''m writing a lightmap-generator for my 3dengine, so I need to determine if a lightray intersects with a triangle, so that shadows can be generated. Thanks, RiBa PS:I can determine the point, where the ray intersects with the triangle''s plane.
so you want to know how to do a google("ray triangle intersection") ?

or something like this?

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Advertisement
I know how to use google, but I find this problem pretty difficult and I tought u guys could help me out a little.

If that disturbs you somehow, I am very sorry.
Well, three points define a plane, so if you have a fourth point, you can plug it into the plane equation and see if it works (or at least is within a really close epsilon value).

I also remember writing up how to do a ray-triangle intersection earlier. I know "Search" is down, but try going back a few months, or use Google to search the site (I''ve heard it can be done )
quote:
Original post by Zipster
Well, three points define a plane, so if you have a fourth point, you can plug it into the plane equation and see if it works (or at least is within a really close epsilon value).



Hey, nice idea, I''m gonna try that right away, thanks!
not sure if this is exactly what you''re looking for, but if you have a ray, find the perpendicular intersection point with the plane, once you found this point and you know it lies on the plane, take the angles of each point of the triangle with the point you just found, and add them up. if they add up to ~360 degrees, it''s inside. if not, then it''s not.

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Advertisement
quote:
Original post by RiBa
I know how to use google, but I find this problem pretty difficult and I tought u guys could help me out a little.

If that disturbs you somehow, I am very sorry.


i thought you want code, sorry..

the way i understood it best is with plueckerspace.. well.. plueckerspace itself is not easy, so..

but bether think about ray-triangle intersections, not the i''m yet on the triangle how to determine it now. it''s not easier then imho..

so..

if you take one edge of your triangle, and the starting point of your ray, those are 3 points.. so you could build up a plane with them. "rotate" by one edge, next plane. and the third plane, too, of course.. now, you can make the math so that all those 3 planes look inwards (the plane normal faces to each others..). now you could check simply if the directional ray is facing onto the triangle by checking it against the 3 planes.. is it "in" that hm.. "trianglular pyramid" ? thats 3 dotproducts if i''m right.. basically you just need the 3 normals of the 3 faces me thinks.. and those you can get quick me thinks..

hope this inspires you..

btw, if you''re for working code, check google:D the first hit is some of the best

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

when you've got the intersection point between the ray and the plane of the polygon, you just need to know if the point lies inside the poly.

This might help: http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/

what a2k say is described there, too...

[edited by - -IceDragon- on October 30, 2002 6:32:00 AM]
Thanks for the feedback guys, I have a found a solution :
I''ve used something similar to what davepermen described.

Like this:
http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast/sld018.htm

This topic is closed to new replies.

Advertisement