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) {
|
||||
double xhalf = 0.5d * x;
|
||||
long i = Double.doubleToLongBits(x);
|
||||
i = 0x5fe6ec85e7de30daL - (i >> 1);
|
||||
x = Double.longBitsToDouble(i);
|
||||
x *= (1.5d - xhalf * x * x);
|
||||
return x;
|
||||
double halfX = 0.5d * x;
|
||||
long i = Double.doubleToLongBits(x); // evil floating point bit level hacking
|
||||
i = 0x5FE6EC85E7DE30DAL - (i >> 1); // what the fuck?
|
||||
double y = Double.longBitsToDouble(i);
|
||||
y *= (1.5d - halfX * y * y); // 1st newtonian iteration
|
||||
// y *= (1.5d - halfX * y * y); // 2nd newtonian iteration, this can be removed
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user