Normals and Dot products
I am writing a ray tracing algorithm for my collision detection and am having problems. I am trying to find if a finite length ray intersects a triangle.
At the moment i have calculated the point where the ray intersects the plane. My book then tells me to project the triangle into a 2D plane (my example tri is into the X-Y plane)
I am then left with my triangles 3 2D vertex values (z is discarded). Now my book tells me to calculate the normals for each edge of the triangle and take the dot product of each normal and the point at which my ray intersected the triangles plane. if the sign of each dot product is the same then the point should lie inside the triangles edges.
One question i have is how to calculate the perpendicular normals in 2D for each edge.
Another question is, will this method work for all triangles? I am using a right triangle for my example but what about more irregular triangles.
I am differing slightly from how the book does it. Once the tri is projected into a 2D plane It says to :
"Compute the two dimensional differences :
E = P(i-1) mod 3 - Pi
F = P(i+2) mod 3 - pi
G = P - Pi
essentially shifting our coordinate system so that vertex i lies at the origin."
I don''t understand what it means with the above math. It seems to contradict itself saying that ''i'' is a vertex and that E,F,G represent the 2D triangles edges. P is the 3D intersection point where the ray hit the original triangles plane.
Any help anyone can give me here is much appreciated.
December 10, 2002 01:27 PM
Do a Google search on the topic. There are several algorithms for ray-triangle intersection, and you can find articles discussing the relative merits of each approach -- plus working, optimized source code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement