Package com.fastasyncworldedit.core.util
Class MathMan
java.lang.Object
com.fastasyncworldedit.core.util.MathMan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
absByte
(int value) static float
atan2
(float i, float j) static int
ceilZero
(float floatNumber) static long
chunkXZ2Int
(int x, int z) static float
clamp
(float check, float min, float max) static int
clamp
(int check, int min, int max) static float
cosInexact
(double paramFloat) static int
floorZero
(double d0) static int
gcd
(int[] a) static int
gcd
(int a, int b) static float[]
getDirection
(float yaw, float pitch) Returns [x, y, z].static double
getMean
(double[] array) static double
getMean
(int[] array) static float[]
getPitchAndYaw
(float x, float y, float z) Returns [ pitch, yaw ].static double
getSD
(double[] array, double av) static double
getSD
(int[] array, double av) static double
hypot
(double... pars) static double
hypot2
(double... pars) static long
inverseRound
(double val) static float
invSqrt
(float x) static boolean
isInteger
(CharSequence str) static boolean
isPowerOfTwo
(int a) static int
log2nlz
(int bits) static int
lossyFastDivide
(int a, int b) static double
max
(double... values) static int
max
(int... values) static double
min
(double... values) static int
min
(int... values) static int
mod
(int a, int b) static int
pair
(short x, short y) static byte
pair16
(int x, int y) static byte
pair8
(int x, int y) static short
pairByte
(int a, int b) static long
pairInt
(int a, int b) Used to convert a set of coordinates into a packed long.static int
pairSearchCoords
(int x, int y) static int
roundInt
(double value) static float
sinInexact
(double paramFloat) static int
sqr
(int val) static double
sqrtApprox
(double d) static float
sqrtApprox
(float f) static int
tripleBlockCoord
(int x, int y, int z) Pack a chunk-block coordinate into an int.static char
tripleBlockCoordChar
(int x, int y, int z) static int
tripleSearchCoords
(int x, int y, int z) Obtain an integer representation of 3 ints, x, y and z.static long
tripleWorldCoord
(int x, int y, int z) static byte
unpair16x
(byte value) static byte
unpair16y
(byte value) static byte
unpair8x
(int value) static byte
unpair8y
(int value) static int
unpairIntX
(long pair) static int
unpairIntY
(long pair) static int
unpairSearchCoordsX
(int pair) static int
unpairSearchCoordsY
(int pair) static byte
unpairShortX
(short pair) static byte
unpairShortY
(short pair) static short
unpairX
(int hash) static short
unpairY
(int hash) static int
unsignedMod
(int a, int b) static int
untripleBlockCoordX
(int triple) static int
untripleBlockCoordY
(int triple) static int
untripleBlockCoordZ
(int triple) static long
untripleWorldCoordX
(long triple) static long
untripleWorldCoordY
(long triple) static long
untripleWorldCoordZ
(long triple) static int
usqrt
(int a) An optimized version ofMath.sqrt(double)
that accepts integers.static int
wrap
(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)
-