# The fastest way to detect a line intersect with triangles in 3D

This topic is 3846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

what is the fastest way to detect a line intersect with triangles in 3D? and This line has defined start point and end point. (including passing the vertex or edge of the triangle) and then pass back the intersected triangle. Thx~

##### Share on other sites
this is most probably the fastest algorithm that doesn't require precomputed data. Other ways exist that use some precomputations to speedup things. If your're going to use it for real time (and you have a lot of intersections) then perhaps you may want to give a look to those algos (Jacco Bikker implemented one of them in his series of tutorial about raytracing. You can give a look to www.realtimerendering.com geometric intersection reference.

##### Share on other sites
Quote:
 Original post by cignox1this is most probably the fastest algorithm that doesn't require precomputed data. Other ways exist that use some precomputations to speedup things. If your're going to use it for real time (and you have a lot of intersections) then perhaps you may want to give a look to those algos (Jacco Bikker implemented one of them in his series of tutorial about raytracing. You can give a look to www.realtimerendering.com geometric intersection reference.

does this method consider the line which has defined start point and end point?
thx

##### Share on other sites
Quote:
Original post by gohkgohk
Quote:
 Original post by cignox1this is most probably the fastest algorithm that doesn't require precomputed data. Other ways exist that use some precomputations to speedup things. If your're going to use it for real time (and you have a lot of intersections) then perhaps you may want to give a look to those algos (Jacco Bikker implemented one of them in his series of tutorial about raytracing. You can give a look to www.realtimerendering.com geometric intersection reference.

does this method consider the line which has defined start point and end point?
thx

Rays are usually defined as a point (origin) and as a normalized vector (direction). These algorithms usually suppose the ray to be defined this way, but you can convert from one representation to another without troubles:

if your segment has two points START and END then you use this (pseudocode):

ray.origin = START;
ray.direction = END - START;
normalize(ray.direction);

Actually, you may encounter a few problems:
-if you want your ray to be of finite lenght, you must have another variable with the lenght (in your case ray.length = LENGTH(END - START); )
-Normalization requires a sqrt(): the less sqrt you have the better. Usually you need to normalize it anyway tough, so perhaps is not really a problem.

I suggest to use the parametric representation, I've seen it in every raytracer that I know: you always need the direction (i.e. for shading) so it is better to have it ready to use instead than calculating it everytime (sqrt() ghost :-)

Hope this helps

1. 1
2. 2
3. 3
Rutin
20
4. 4
frob
20
5. 5

• 32
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632559
• Total Posts
3007080

×