mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
improve invSqrt formatting
Co-authored-by: solonovamax <solonovamax@12oclockpoint.com> what the fuck?
This commit is contained in:
parent
dd7bebb27f
commit
0df940d688
@ -60,12 +60,14 @@ public final class MathUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double invSqrt(double x) {
|
public static double invSqrt(double x) {
|
||||||
double xhalf = 0.5d * x;
|
double halfX = 0.5d * x;
|
||||||
long i = Double.doubleToLongBits(x);
|
long i = Double.doubleToLongBits(x); // evil floating point bit level hacking
|
||||||
i = 0x5fe6ec85e7de30daL - (i >> 1);
|
i = 0x5FE6EC85E7DE30DAL - (i >> 1); // what the fuck?
|
||||||
x = Double.longBitsToDouble(i);
|
double y = Double.longBitsToDouble(i);
|
||||||
x *= (1.5d - xhalf * x * x);
|
y *= (1.5d - halfX * y * y); // 1st newtonian iteration
|
||||||
return x;
|
// y *= (1.5d - halfX * y * y); // 2nd newtonian iteration, this can be removed
|
||||||
|
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user