From 3a441e33296fa603a97f52ae3cc339b44c456d20 Mon Sep 17 00:00:00 2001 From: Esophose Date: Tue, 25 Aug 2020 18:44:41 -0600 Subject: [PATCH] Use doubles instead of floats for MathL --- .../esophose/playerparticles/util/MathL.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/dev/esophose/playerparticles/util/MathL.java b/src/main/java/dev/esophose/playerparticles/util/MathL.java index 169161d..fde7434 100644 --- a/src/main/java/dev/esophose/playerparticles/util/MathL.java +++ b/src/main/java/dev/esophose/playerparticles/util/MathL.java @@ -7,39 +7,39 @@ package dev.esophose.playerparticles.util; public final class MathL { private static final int SIN_BITS, SIN_MASK, SIN_COUNT; - private static final float radFull, radToIndex; - private static final float degFull, degToIndex; - private static final float[] sin, cos; + private static final double radFull, radToIndex; + private static final double degFull, degToIndex; + private static final double[] sin, cos; static { SIN_BITS = 12; SIN_MASK = ~(-1 << SIN_BITS); SIN_COUNT = SIN_MASK + 1; - radFull = (float) (Math.PI * 2.0); - degFull = (float) (360.0); + radFull = Math.PI * 2.0; + degFull = 360.0; radToIndex = SIN_COUNT / radFull; degToIndex = SIN_COUNT / degFull; - sin = new float[SIN_COUNT]; - cos = new float[SIN_COUNT]; + sin = new double[SIN_COUNT]; + cos = new double[SIN_COUNT]; for (int i = 0; i < SIN_COUNT; i++) { - sin[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * radFull); - cos[i] = (float) Math.cos((i + 0.5f) / SIN_COUNT * radFull); + sin[i] = Math.sin((i + 0.5f) / SIN_COUNT * radFull); + cos[i] = Math.cos((i + 0.5f) / SIN_COUNT * radFull); } for (int i = 0; i < 360; i += 90) { - sin[(int) (i * degToIndex) & SIN_MASK] = (float) Math.sin(i * Math.PI / 180.0); - cos[(int) (i * degToIndex) & SIN_MASK] = (float) Math.cos(i * Math.PI / 180.0); + sin[(int) (i * degToIndex) & SIN_MASK] = Math.sin(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]; } - public static float cos(double rad) { + public static double cos(double rad) { return cos[(int) (rad * radToIndex) & SIN_MASK]; }