• Create Account

### #ActualShawn619

Posted 07 June 2013 - 02:55 PM

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 http://www.angelfire.com/fl/houseofbartlett/solutions/line2tri.html#Code

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?

### #1Shawn619

Posted 07 June 2013 - 02:54 PM

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 http://www.angelfire.com/fl/houseofbartlett/solutions/line2tri.html#Code

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 an 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?

PARTNERS