mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 03:29:53 +00:00
Use doubles instead of floats for MathL
This commit is contained in:
parent
09fdeaf612
commit
3a441e3329
1 changed files with 13 additions and 13 deletions
|
@ -7,39 +7,39 @@ package dev.esophose.playerparticles.util;
|
||||||
public final class MathL {
|
public final class MathL {
|
||||||
|
|
||||||
private static final int SIN_BITS, SIN_MASK, SIN_COUNT;
|
private static final int SIN_BITS, SIN_MASK, SIN_COUNT;
|
||||||
private static final float radFull, radToIndex;
|
private static final double radFull, radToIndex;
|
||||||
private static final float degFull, degToIndex;
|
private static final double degFull, degToIndex;
|
||||||
private static final float[] sin, cos;
|
private static final double[] sin, cos;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SIN_BITS = 12;
|
SIN_BITS = 12;
|
||||||
SIN_MASK = ~(-1 << SIN_BITS);
|
SIN_MASK = ~(-1 << SIN_BITS);
|
||||||
SIN_COUNT = SIN_MASK + 1;
|
SIN_COUNT = SIN_MASK + 1;
|
||||||
|
|
||||||
radFull = (float) (Math.PI * 2.0);
|
radFull = Math.PI * 2.0;
|
||||||
degFull = (float) (360.0);
|
degFull = 360.0;
|
||||||
radToIndex = SIN_COUNT / radFull;
|
radToIndex = SIN_COUNT / radFull;
|
||||||
degToIndex = SIN_COUNT / degFull;
|
degToIndex = SIN_COUNT / degFull;
|
||||||
|
|
||||||
sin = new float[SIN_COUNT];
|
sin = new double[SIN_COUNT];
|
||||||
cos = new float[SIN_COUNT];
|
cos = new double[SIN_COUNT];
|
||||||
|
|
||||||
for (int i = 0; i < SIN_COUNT; i++) {
|
for (int i = 0; i < SIN_COUNT; i++) {
|
||||||
sin[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * radFull);
|
sin[i] = Math.sin((i + 0.5f) / SIN_COUNT * radFull);
|
||||||
cos[i] = (float) Math.cos((i + 0.5f) / SIN_COUNT * radFull);
|
cos[i] = Math.cos((i + 0.5f) / SIN_COUNT * radFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 360; i += 90) {
|
for (int i = 0; i < 360; i += 90) {
|
||||||
sin[(int) (i * degToIndex) & SIN_MASK] = (float) Math.sin(i * Math.PI / 180.0);
|
sin[(int) (i * degToIndex) & SIN_MASK] = Math.sin(i * Math.PI / 180.0);
|
||||||
cos[(int) (i * degToIndex) & SIN_MASK] = (float) Math.cos(i * Math.PI / 180.0);
|
cos[(int) (i * degToIndex) & SIN_MASK] = Math.cos(i * Math.PI / 180.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float sin(double rad) {
|
public static double sin(double rad) {
|
||||||
return sin[(int) (rad * radToIndex) & SIN_MASK];
|
return sin[(int) (rad * radToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float cos(double rad) {
|
public static double cos(double rad) {
|
||||||
return cos[(int) (rad * radToIndex) & SIN_MASK];
|
return cos[(int) (rad * radToIndex) & SIN_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue