package in.twizmwaz.cardinal.util;
import org.bukkit.util.Vector;
import java.util.Random;
public class Numbers {
public static boolean checkInterval(double test, double bound1, double bound2) {
return (test >= bound1 && test <= bound2) || (test >= bound2 && test <= bound1);
}
public static double hypotSphere(double x, double y, double z) {
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
}
public static double getRandom(double min, double max) {
return new Random().nextInt((int) (max - min) + 1) + min;
}
public static double parseDouble(String string) {
if (string.equalsIgnoreCase("oo")) return Double.POSITIVE_INFINITY;
if (string.equalsIgnoreCase("-oo")) return Double.NEGATIVE_INFINITY;
return Double.parseDouble(string);
}
public static double parseDouble(String string, double fallback) {
if (string == null) return fallback;
return parseDouble(string);
}
public static int parseInt(String string) {
if (string.equalsIgnoreCase("oo")) return Integer.MAX_VALUE;
if (string.equalsIgnoreCase("-oo")) return Integer.MIN_VALUE;
return Integer.parseInt(string);
}
public static int parseInt(String string, int fallback) {
if (string == null) return fallback;
return parseInt(string);
}
public static boolean parseBoolean(String string) {
return string.equalsIgnoreCase("on") || !string.equalsIgnoreCase("off") && Boolean.parseBoolean(string);
}
public static boolean parseBoolean(String string, boolean fallback) {
if (string == null) return fallback;
return parseBoolean(string);
}
public static double limitDouble(double min, double max, double value) {
return Math.max(min, Math.min(max, value));
}
public static String convertToSubscript(double number) {
if (number == Double.POSITIVE_INFINITY) return "\u221E";
if (number == Double.NEGATIVE_INFINITY) return "-\u221E";
return (number + "").replaceAll("0", "\u2080").replaceAll("1", "\u2081").replaceAll("2", "\u2082").replaceAll("3", "\u2083").replaceAll("4", "\u2084").replaceAll("5", "\u2085").replaceAll("6", "\u2086").replaceAll("7", "\u2087").replaceAll("8", "\u2088").replaceAll("9", "\u2089");
}
public static Vector clone(Vector other) {
return new Vector(other.getX(), other.getY(), other.getZ());
}
}