Ecere Software
/
sdk
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3b3f463
)
ecere/gfx3D/Vector3D: Added double version of fast invert sqrt
author
Jerome St-Louis
<jerome@ecere.com>
Thu, 16 Oct 2014 22:08:25 +0000
(18:08 -0400)
committer
Jerome St-Louis
<jerome@ecere.com>
Fri, 20 Feb 2015 15:39:14 +0000
(10:39 -0500)
ecere/src/gfx/3D/Vector3D.ec
patch
|
blob
|
history
diff --git
a/ecere/src/gfx/3D/Vector3D.ec
b/ecere/src/gfx/3D/Vector3D.ec
index
6f22618
..
dd087a3
100644
(file)
--- a/
ecere/src/gfx/3D/Vector3D.ec
+++ b/
ecere/src/gfx/3D/Vector3D.ec
@@
-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;