Class MathMan

java.lang.Object
com.fastasyncworldedit.core.util.MathMan

public class MathMan extends Object
  • Constructor Details

    • MathMan

      public MathMan()
  • Method Details

    • usqrt

      public static int usqrt(int a)
      An optimized version of Math.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 coordinate
      b - 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 coordinate
      y - y coordinate
      z - 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 value
      y - y value
      z - 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

      public static boolean isInteger(CharSequence str)
    • 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)