Package com.fastasyncworldedit.core.util
Class MathMan
java.lang.Object
com.fastasyncworldedit.core.util.MathMan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intabsByte(int value) static floatatan2(float i, float j) static intceilZero(float floatNumber) static longchunkXZ2Int(int x, int z) static floatclamp(float check, float min, float max) static intclamp(int check, int min, int max) static floatcosInexact(double paramFloat) static intfloorZero(double d0) static intgcd(int[] a) static intgcd(int a, int b) static float[]getDirection(float yaw, float pitch) Returns [x, y, z].static doublegetMean(double[] array) static doublegetMean(int[] array) static float[]getPitchAndYaw(float x, float y, float z) Returns [ pitch, yaw ].static doublegetSD(double[] array, double av) static doublegetSD(int[] array, double av) static doublehypot(double... pars) static doublehypot2(double... pars) static longinverseRound(double val) static floatinvSqrt(float x) static booleanisInteger(CharSequence str) static booleanisPowerOfTwo(int a) static intlog2nlz(int bits) static intlossyFastDivide(int a, int b) static doublemax(double... values) static intmax(int... values) static doublemin(double... values) static intmin(int... values) static intmod(int a, int b) static intpair(short x, short y) static bytepair16(int x, int y) static bytepair8(int x, int y) static shortpairByte(int a, int b) static longpairInt(int a, int b) Used to convert a set of coordinates into a packed long.static intpairSearchCoords(int x, int y) static introundInt(double value) static floatsinInexact(double paramFloat) static intsqr(int val) static doublesqrtApprox(double d) static floatsqrtApprox(float f) static inttripleBlockCoord(int x, int y, int z) Pack a chunk-block coordinate into an int.static chartripleBlockCoordChar(int x, int y, int z) static inttripleSearchCoords(int x, int y, int z) Obtain an integer representation of 3 ints, x, y and z.static longtripleWorldCoord(int x, int y, int z) static byteunpair16x(byte value) static byteunpair16y(byte value) static byteunpair8x(int value) static byteunpair8y(int value) static intunpairIntX(long pair) static intunpairIntY(long pair) static intunpairSearchCoordsX(int pair) static intunpairSearchCoordsY(int pair) static byteunpairShortX(short pair) static byteunpairShortY(short pair) static shortunpairX(int hash) static shortunpairY(int hash) static intunsignedMod(int a, int b) static intuntripleBlockCoordX(int triple) static intuntripleBlockCoordY(int triple) static intuntripleBlockCoordZ(int triple) static longuntripleWorldCoordX(long triple) static longuntripleWorldCoordY(long triple) static longuntripleWorldCoordZ(long triple) static intusqrt(int a) An optimized version ofMath.sqrt(double)that accepts integers.static intwrap(int value, int min, int max)
-
Constructor Details
-
MathMan
public MathMan()
-
-
Method Details
-
usqrt
public static int usqrt(int a) An optimized version ofMath.sqrt(double)that accepts integers.- Parameters:
a- a value- Returns:
- the positive square root of
a. If the argument is NaN or less than zero, the result is NaN.
-
sinInexact
public static float sinInexact(double paramFloat) -
cosInexact
public static float cosInexact(double paramFloat) -
log2nlz
public static int log2nlz(int bits) -
floorZero
public static int floorZero(double d0) -
max
public static double max(double... values) -
max
public static int max(int... values) -
min
public static int min(int... values) -
min
public static double min(double... values) -
ceilZero
public static int ceilZero(float floatNumber) -
sqr
public static int sqr(int val) -
clamp
public static int clamp(int check, int min, int max) -
clamp
public static float clamp(float check, float min, float max) -
hypot
public static double hypot(double... pars) -
hypot2
public static double hypot2(double... pars) -
wrap
public static int wrap(int value, int min, int max) -
inverseRound
public static long inverseRound(double val) -
pair
public static int pair(short x, short y) -
unpairX
public static short unpairX(int hash) -
unpairY
public static short unpairY(int hash) -
pairByte
public static short pairByte(int a, int b) -
unpairShortX
public static byte unpairShortX(short pair) -
unpairShortY
public static byte unpairShortY(short pair) -
pairInt
public static long pairInt(int a, int b) Used to convert a set of coordinates into a packed long.- Parameters:
a- typically, represents the x coordinateb- typically, represents the y coordinate- Returns:
- the packed coordinates
-
tripleWorldCoord
public static long tripleWorldCoord(int x, int y, int z) -
untripleWorldCoordX
public static long untripleWorldCoordX(long triple) -
untripleWorldCoordY
public static long untripleWorldCoordY(long triple) -
untripleWorldCoordZ
public static long untripleWorldCoordZ(long triple) -
tripleBlockCoord
public static int tripleBlockCoord(int x, int y, int z) Pack a chunk-block coordinate into an int. Supports x and z 0 -> 15 and y = -2048 -> 2047- Parameters:
x- x coordinatey- y coordinatez- z coordinate- Returns:
- int packed by x, y and z coordinates
-
tripleBlockCoordChar
public static char tripleBlockCoordChar(int x, int y, int z) -
untripleBlockCoordX
public static int untripleBlockCoordX(int triple) -
untripleBlockCoordY
public static int untripleBlockCoordY(int triple) -
untripleBlockCoordZ
public static int untripleBlockCoordZ(int triple) -
tripleSearchCoords
public static int tripleSearchCoords(int x, int y, int z) Obtain an integer representation of 3 ints, x, y and z. y is represented by the right-most 9 bits and can be within the range -256 to 255 (inclusive). x and z are represented by 11 bits each and can be within the range -1024 to 1023 (inclusive).- Parameters:
x- x valuey- y valuez- z value- Returns:
- integer representation of x y z
-
pairSearchCoords
public static int pairSearchCoords(int x, int y) -
unpairSearchCoordsX
public static int unpairSearchCoordsX(int pair) -
unpairSearchCoordsY
public static int unpairSearchCoordsY(int pair) -
chunkXZ2Int
public static long chunkXZ2Int(int x, int z) -
unpairIntX
public static int unpairIntX(long pair) -
unpairIntY
public static int unpairIntY(long pair) -
pair16
public static byte pair16(int x, int y) -
unpair16x
public static byte unpair16x(byte value) -
unpair16y
public static byte unpair16y(byte value) -
pair8
public static byte pair8(int x, int y) -
unpair8x
public static byte unpair8x(int value) -
unpair8y
public static byte unpair8y(int value) -
lossyFastDivide
public static int lossyFastDivide(int a, int b) -
gcd
public static int gcd(int a, int b) -
gcd
public static int gcd(int[] a) -
getMean
public static double getMean(int[] array) -
getMean
public static double getMean(double[] array) -
getDirection
public static float[] getDirection(float yaw, float pitch) Returns [x, y, z]. -
roundInt
public static int roundInt(double value) -
getPitchAndYaw
public static float[] getPitchAndYaw(float x, float y, float z) Returns [ pitch, yaw ]. -
atan2
public static float atan2(float i, float j) -
sqrtApprox
public static float sqrtApprox(float f) -
sqrtApprox
public static double sqrtApprox(double d) -
invSqrt
public static float invSqrt(float x) -
isInteger
-
getSD
public static double getSD(double[] array, double av) -
getSD
public static double getSD(int[] array, double av) -
absByte
public static int absByte(int value) -
mod
public static int mod(int a, int b) -
unsignedMod
public static int unsignedMod(int a, int b) -
isPowerOfTwo
public static boolean isPowerOfTwo(int a)
-