I'm sorry, this whole function is just majorly screwed up.

1. Why is it outside of box.js? Box is the only code that uses it. It should almost certainly be inside box.js, since it relies on the internal representation of the bounding box as an array.
2. This is extremely complex for something that should ultimately be quite simple.
3. Why does it use an array? Maybe I'm just weird, but I find `xs`, `xe` much easier to understand than `curPos[0]`, `curPos[3]`
4. These changes are (as far as I can tell) wholly unrelated to lag induction. So they shouldn't be on this branch. More changes at once makes the code a pain to review, increases likelyhood of conflicts when many people are working, and means more likelyhood of inadvertently introducing bugs. If it aint broke, don't fix it.