ecere/gfx3D/Vector3D: Added double version of fast invert sqrt
authorJerome St-Louis <jerome@ecere.com>
Thu, 16 Oct 2014 22:08:25 +0000 (18:08 -0400)
committerJerome St-Louis <jerome@ecere.com>
Fri, 20 Feb 2015 15:39:14 +0000 (10:39 -0500)
ecere/src/gfx/3D/Vector3D.ec

index 6f22618..dd087a3 100644 (file)
@@ -161,6 +161,16 @@ public /*inline */float FastInvSqrt(float x)
   return x * (1.5f - (halfX * x * x));
 }
 
+public /*inline */double FastInvSqrtDouble(double x)
+{
+   union { double d; uint64 u; } i;
+   double halfX = x / 2;
+   i.d = x;
+   i.u = 0x5fe6eb50c7b537a9LL - (i.u >> 1);
+   x = i.d;
+   return x * (1.5 - (halfX * x * x));
+}
+
 public struct Vector3Df
 {
    float x, y, z;