This function as a whole is pretty difficult to understand and the variable names aren't helpful. That said, the papers I've looked at aren't terribly enlightening. Telea's 2002 paper might be a better reference here and maybe Sethian's 1996 paper (specifically section 4) would be useful, but I can't honestly say that I really follow it.