Home > Flash, Math > haXe and fast inverse square root

haXe and fast inverse square root

November 22, 2008

Inverse square root is a common operation in vector normalization, something that happens a lot in 3D math, particularly in game engines.  An incredibly clever algorithm was developed using so-called ‘magic numbers’ and implemented in C, making its production debut in Quake.

Essentially, the algorithm makes a very smart guess as to an initial starting point that can be used to drive a single iteration of Newton’s method for 1/sqrt(x).  You can read more about it here,




Some time ago, I gave this approach a try using ByteArray and was disappointed with the performance, although it was a fun exercise.  Recently, Nicolas Cannasse implemented the algorithm with haXe optimizations and the performance is awesome.  Great work Nicolas!

%d bloggers like this: