package io.gitlab.jfronny.quickmeth; import net.minecraft.util.math.MathHelper; import java.util.Random; public class MathUtil { private static final float[] SIN_TABLE_FAST = new float[4096]; private static final float radToIndex = 651.8986469044033F; static { Random rng = new Random(0); for (int j = 0; j < SIN_TABLE_FAST.length; ++j) { SIN_TABLE_FAST[j] = rng.nextFloat() * 2 - 1; } } public static double boxedInvert(double min, double max, double value) { return max - value + min; } public static double boxedInvert(double value) { return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value); } public static float boxedInvert(float min, float max, float value) { return max - value + min; } public static float boxedInvert(float value) { return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value); } public static long boxedInvert(long min, long max, long value) { return max - value + min; } public static long boxedInvert(long value) { return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value); } public static int boxedInvert(int min, int max, int value) { return max - value + min; } public static int boxedInvert(int value) { return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value); } public static float sin(float value) { return SIN_TABLE_FAST[(int) (value * radToIndex) & 4095]; } }