Original Post
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. This code was used from here: http://www.blitzbasic.com/codearcs/codearcs.php?code=1029 but there is not commenting at all and the variable names lack what they do. Thanks in advance guys!
Local txmin#,txmax#,tymin#,tymax#
Local ddx#=1.0/(rox-rdx)
Local ddy#=1.0/(roy-rdy)
If ddx >= 0
txmin = (bminx - rox) * ddx
txmax = (bmaxx - rox) * ddx
Else
txmin = (bmaxx - rox) * ddx
txmax = (bminx - rox) * ddx
EndIf
If ddy >= 0
tymin = (bminy - roy) * ddy
tymax = (bmaxy - roy) * ddy
Else
tymin = (bmaxy - roy) * ddy
tymax = (bminy - roy) * ddy
EndIf
If ( (txmin > tymax) Or (tymin > txmax) ) Return 0
If (tymin > txmin) txmin = tymin
If (tymax < txmax) txmax = tymax
Local tzmin#,tzmax#
Local ddz#=1.0/(roz-rdz)
If ddz >= 0
tzmin = (bminz - roz) * ddz
tzmax = (bmaxz - roz) * ddz
Else
tzmin = (bmaxz - roz) * ddz
tzmax = (bminz - roz) * ddz
EndIf
If (txmin > tzmax) Or (tzmin > txmax) Return 0
Return 1
End Function