I am trying to implement this algorithm but am not sure how I am supposed to represent my ray and my line segments(walls).

For the r_px/r_py do I just use the position of the light? For the r_dx/r_dy do I just use the normalized vector pointing from the light position to the direction of the ray?

For the s_px/s_py do I just use the location of one of the two points of the line segment. Finally for the s_dx/s_dy do I just use the normalized vector pointing from the first point, to the second point?


  • \$\begingroup\$ This appears to just be interesecting two line segments. You are correct about r_px, r_py, r_dx, r_dy etc. But this question needs more details to form a good answer. You should try to understand why it is that this is how you find the intersection between two line segments. \$\endgroup\$
    – mklingen
    Feb 23, 2015 at 22:29
  • \$\begingroup\$ Thanks, I understand why but was just having an issue seeing where things go. However, I think that I am wrong when I say that the line segment direction is normalized. If you scroll down it states that 0<T2<1. Doesn't that mean that if the vector is normalized it will only check for intersection on a minuscule portion of the line/wall. Am I right in the statement that it stays normalized for the ray as it is 0<T1 and not clamped to 1? Thanks! \$\endgroup\$
    – Moo
    Feb 24, 2015 at 2:33

1 Answer 1


mklingen's comment answered my question. I was correct in my initial guess.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .