Sign in to follow this  


Recommended Posts

Shawn619    342

I'm not quite sure which section this question be better suited, so feel free to move it.


This question is about raytracing line-triangle, more specifically, a vertical line intersecting with a triangle.


I'm following the algorithm from


Goal: Place a vertical line anywhere on a non-flat surface(terrain) and be able to detect which triangle it hits. 


I'll try to make my question simple:


When my line point starts above the terrain and has a negative vertical vector direction(enough to pierce the terrain and create intersection), I produce correct results: 



//vertical line from 10y to -10y
vec3f linept = {0.0, 10.0, 0.0}; //start line point
vec3f linevect = {0.0, -20.0, 0.0}; // line vector direction




*the black triangle means the line-triangle algorithm has returned true for that polygon.


While simply having the line start below the terrain, instead of the top, and changing the direction of the line direction(from down->top), which you would think have no effect and still pierce the terrain because it's really still the same line, now does not recognize intersecting with the triangle:



//vertical line from -10y to 10y
vec3f linept = {0.0, -10.0, 0.0}; //start line point
vec3f linevect = {0.0, 20.0, 0.0}; // line vector direction




*the algorithm does not deal with normalized vectors of direction, so that's why the line's direction is (0,10,0) instead of (0,1,0).


Why does changing the vector direction make the algorithm fail?

Edited by Shawn619

Share this post

Link to post
Share on other sites

The dot product between the normal of the surface and your intersection vector will be > 0 and thus fail the if test in the intersection test.


This means that the intersection test is designed to use back-face culling, i.e. the back of a triangles are not visible.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this