What do the ddx and ddy values do in this AABB ray intersect algorithm?
Posted
by Paz
on Stack Overflow
See other posts from Stack Overflow
or by Paz
Published on 2010-05-31T13:07:04Z
Indexed on
2010/06/02
1:03 UTC
Read the original article
Hit count: 420
Does anyone know what the ddx and ddy values do in the AABB ray intersect algorithm? Taken from the following site http://www.blitzbasic.com/codearcs/codearcs.php?code=1029 (show below).
Local txmin#,txmax#,tymin#,tymax#
// rox, rdx are the ray origin on the x axis, and ray delta on the x axis ... y-axis is roy and rdy
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
© Stack Overflow or respective owner