   Quick Question on this code
  I'm trying to figure out the use of this AABB intersection algorithm. But can't seem to figure out what the variables txMin, txMax ... and ddx, ddy are doing.Some advice would be highly approciated.Local txmin#,txmax#,tymin#,tymax#Local ddx#=1.0/(rox-rdx)Local ddy#=1.0/(roy-rdy)If ddx &gt;= 0txmin = (bminx - rox) * ddxtxmax = (bmaxx - rox) * ddxElsetxmin = (bmaxx - rox) * ddxtxmax = (bminx - rox) * ddxEndIf If ddy &gt;= 0tymin = (bminy - roy) * ddytymax = (bmaxy - roy) * ddyElsetymin = (bmaxy - roy) * ddytymax = (bminy - roy) * ddyEndIfIf ( (txmin &gt; tymax) Or (tymin &gt; txmax) ) Return 0If (tymin &gt; txmin) txmin = tyminIf (tymax &lt; txmax) txmax = tymaxLocal tzmin#,tzmax#Local ddz#=1.0/(roz-rdz)If ddz &gt;= 0tzmin = (bminz - roz) * ddztzmax = (bmaxz - roz) * ddzElsetzmin = (bmaxz - roz) * ddztzmax = (bminz - roz) * ddzEndIfIf (txmin &gt; tzmax) Or (tzmin &gt; txmax) Return 0Return 1End FunctionThis code was used from here:http://www.blitzbasic.com/codearcs/codearcs.php?code=1029but there is not commenting at all and the variable names lack what they do.Thanks in advance guys!   
  It's a little hard to read, but it looks like a slab-based ray-AABB intersection test (the 'min' and 'max' variables are parametric values corresponding to the points at which the ray enters and leaves the three 'slabs' - one for each dimension - that make up the box).This test has been discussed frequently here in the past, so if you search the archives for (e.g.) 'ray aabb intersection', you'll probably be able to find some discussion of the algorithm and/or other implementations that you can check this code against.   ;Quote:Original post by jykIt's a little hard to read, but it looks like a slab-based ray-AABB intersection test (the 'min' and 'max' variables are parametric values corresponding to the points at which the ray enters and leaves the three 'slabs' - one for each dimension - that make up the box).This test has been discussed frequently here in the past, so if you search the archives for (e.g.) 'ray aabb intersection', you'll probably be able to find some discussion of the algorithm and/or other implementations that you can check this code against.Thanks jyk!   