>Math.sqrt(a * a + b * b) could be replaced with Math.hypot(a,b)
hypot is typically much slower than the "naive" computation.
Instead of trying to make all the code handle huge or tiny valuesas well as it
could, which would make it complicated, slow and brittle,and would not
necessarily make sense for graphic stuffs (x * x overflowsnear x = 1e154ish,
which should be well out of the frustum),
what can be done is checking that values are "reasonable" whenthey enter the
program, and that the program doesn't generateproblematic values by itself from
reasonable ones.
-Jeff