diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-10-26 15:46:55 +0100 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-10-26 15:46:55 +0100 |
commit | 2cf05c4deaf3a26626853431f725d0ca375ffec3 (patch) | |
tree | 025ae135b88af6b9a0437a3721bcc2dec9ccc3e3 /src/Java/gtPlusPlus/core/util/math | |
parent | e9dbe58c39b56d562bcdc17b1100a7c26ce7c10e (diff) | |
download | GT5-Unofficial-2cf05c4deaf3a26626853431f725d0ca375ffec3.tar.gz GT5-Unofficial-2cf05c4deaf3a26626853431f725d0ca375ffec3.tar.bz2 GT5-Unofficial-2cf05c4deaf3a26626853431f725d0ca375ffec3.zip |
+ Added 4 new High-Tier Alloys. Lafium, Cinobite, Pikyonite & Abyssal.
+ Added missing Germanium Dust.
+ Added compatibility for Witchery.
- Removed portability of Tanks for GTNH, tanks are still portable otherwise.
$ Fixed calculations for automatic recipe generation, EBF and ABS recipe requirements for GT++ Alloys are now significantly increased.
$ Fixed missing Control Core textures.
% Cleaned up some recipe generation.
% Improved Material.java.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/math')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/math/MathUtils.java | 107 |
1 files changed, 104 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 7ec898ce3a..03146d20d3 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -357,6 +357,14 @@ public class MathUtils { } } + public static byte safeByte(long number){ + return number>Byte.MAX_VALUE ? Byte.MAX_VALUE :(byte)number; + } + + public static short safeShort(long number){ + return number>Short.MAX_VALUE ? Short.MAX_VALUE :(short)number; + } + public static int safeInt(long number, int margin){ return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number; } @@ -376,15 +384,99 @@ public class MathUtils { } - public static long getAverage(AutoMap aDataSet) { + + /* + * Averages + */ + + public static byte getByteAverage(AutoMap<?> aDataSet) { + byte[] aNewSet = new byte[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (byte) aDataSet.get(u); + } + return getByteAverage(aNewSet); + } + + public static short getShortAverage(AutoMap<?> aDataSet) { + short[] aNewSet = new short[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (short) aDataSet.get(u); + } + return getShortAverage(aNewSet); + } + + public static int getIntAverage(AutoMap<?> aDataSet) { + int[] aNewSet = new int[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (int) aDataSet.get(u); + } + return getIntAverage(aNewSet); + } + + public static float getFloatAverage(AutoMap<?> aDataSet) { + float[] aNewSet = new float[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (float) aDataSet.get(u); + } + return getFloatAverage(aNewSet); + } + + public static long getLongAverage(AutoMap<?> aDataSet) { long[] aNewSet = new long[aDataSet.size()]; for (int u=0;u<aDataSet.size();u++) { aNewSet[u] = (long) aDataSet.get(u); } - return getAverage(aNewSet); + return getLongAverage(aNewSet); } - public static long getAverage(long[] aDataSet) { + public static double getDoubleAverage(AutoMap<?> aDataSet) { + double[] aNewSet = new double[aDataSet.size()]; + for (int u=0;u<aDataSet.size();u++) { + aNewSet[u] = (double) aDataSet.get(u); + } + return getDoubleAverage(aNewSet); + } + + + + public static byte getByteAverage(byte[] aDataSet) { + int divisor = aDataSet.length; + byte total = 0; + for (byte i : aDataSet) { + total += i; + } + byte result = safeByte(total/divisor); + return result; + } + + public static short getShortAverage(short[] aDataSet) { + int divisor = aDataSet.length; + short total = 0; + for (short i : aDataSet) { + total += i; + } + short result = safeShort(total/divisor); + return result; + } + public static int getIntAverage(int[] aDataSet) { + int divisor = aDataSet.length; + int total = 0; + for (int i : aDataSet) { + total += i; + } + int result = safeInt(total/divisor); + return result; + } + public static float getFloatAverage(float[] aDataSet) { + int divisor = aDataSet.length; + float total = 0; + for (float i : aDataSet) { + total += i; + } + float result = (total/divisor); + return result; + } + public static long getLongAverage(long[] aDataSet) { int divisor = aDataSet.length; long total = 0; for (long i : aDataSet) { @@ -393,5 +485,14 @@ public class MathUtils { long result = (total/divisor); return result; } + public static double getDoubleAverage(double[] aDataSet) { + int divisor = aDataSet.length; + double total = 0; + for (double i : aDataSet) { + total += i; + } + double result = (total/divisor); + return result; + } } |