Contents
- Description
- Field Summary
- Method Summary
- Field Details
- Method Details
- abs(int)
- floor(double)
- ceil(double)
- randomInt(int, int)
- randomDouble(double, double)
- randomFloat(float, float)
- round(double, int)
- within(double, double, double)
- minValue(double, double, double)
- minValue(int, int, int)
- maxValue(double, double, double, double)
- maxValue(double, double, double)
- maxValue(byte, byte, byte)
- maxValue(byte, byte, byte, byte)
- maxValue(int, int, int)
- lengthSquared(double, double)
- length(double, double)
- lengthSquared(double, double, double)
- length(double, double, double)
- maxValue(double, double)
- clipToZero(double)
- clipToZero(double, double)
- clipToZero(float)
- clipToZero(float, float)
- closeToZero(double)
- closeToZero(double, double)
- closeToZero(float)
- closeToZero(float, float)
- clamp(double, double, double)
- clamp(float, float, float)
- clamp(int, int, int)
- clamp(long, long, long)
- saturatedMultiply(long, long)
- getPercentageOf(int, int)
- percent(int, int)
- fastRound(float)
- fastRound(double)
- fastFloor(float)
- fastFloor(double)
- fastCeil(float)
- fastCeil(double)
- halfFloatToFloat(int)
- halfFloatFromFloat(float)
- byteCount(int)
- packInt(int, int)
- unpackLeft(int)
- unpackRight(int)
- packLong(int, int)
- unpackLeft(long)
- unpackRight(long)
- rotateVectorYAxis(Vector3i, int, boolean)
- rotateVectorYAxis(Vector3d, int, boolean)
- rotateVectorYAxis(Vector3d, double, boolean)
- wrapAngle(float)
- lerp(float, float, float)
- lerpUnclamped(float, float, float)
- lerp(double, double, double)
- seededLerp(float, float, long)
- lerpUnclamped(double, double, double)
- shortAngleDistance(float, float)
- lerpAngle(float, float, float)
- floorMod(double, double)
- compareAngle(double, double)
- percentile(long[], double)
- distanceToLineSq(double, double, double, double, double, double)
- distanceToLineSq(double, double, double, double, double, double, double, double, double, double)
- distanceToInfLineSq(double, double, double, double, double, double)
- distanceToInfLineSq(double, double, double, double, double, double, double, double)
- sideOfLine(double, double, double, double, double, double)
- getRotationForHitNormal(Vector3d)
- getNameForHitNormal(Vector3d)
- mapToRange(float, float, float, float, float)
Class MathUtil
java.lang.Object
com.hypixel.hytale.math.util.MathUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final floatstatic floatstatic final doubleLength-squared below which a vector is treated as degenerate (effectively zero length), used to guard normalization against producing a non-finite result. -
Method Summary
Modifier and TypeMethodDescriptionstatic intabs(int i) static intbyteCount(int i) static intceil(double d) static doubleclamp(double v, double min, double max) static floatclamp(float v, float min, float max) static intclamp(int v, int min, int max) static longclamp(long v, long min, long max) static doubleclipToZero(double v) static doubleclipToZero(double v, double epsilon) static floatclipToZero(float v) static floatclipToZero(float v, float epsilon) static booleancloseToZero(double v) static booleancloseToZero(double v, double epsilon) static booleancloseToZero(float v) static booleancloseToZero(float v, float epsilon) static doublecompareAngle(double a, double b) static doubledistanceToInfLineSq(double x, double y, double ax, double ay, double bx, double by) Find the distance from point P to its projection onto the infinite line passing through points A and B.static doubledistanceToInfLineSq(double x, double y, double ax, double ay, double dxAx, double dyAy, double dBxAx, double dByAy) Find the distance from point P to its projection onto the infinite line passing through points A and B.static doubledistanceToLineSq(double x, double y, double ax, double ay, double bx, double by) Find the distance from point P to the line AB.static doubledistanceToLineSq(double x, double y, double ax, double ay, double bx, double by, double dxAx, double dyAy, double dBxAx, double dByAy) Find the distance from point P to the line AB.static longfastCeil(double d) static intfastCeil(float f) static longfastFloor(double d) static intfastFloor(float f) static longfastRound(double d) static intfastRound(float f) static intfloor(double d) static doublefloorMod(double x, double y) static StringgetNameForHitNormal(org.joml.Vector3d normal) static intgetPercentageOf(int index, int max) static Rotation3fgetRotationForHitNormal(org.joml.Vector3d normal) static inthalfFloatFromFloat(float fval) static floathalfFloatToFloat(int hbits) static doublelength(double x, double y) static doublelength(double x, double y, double z) static doublelengthSquared(double x, double y) static doublelengthSquared(double x, double y, double z) static doublelerp(double a, double b, double t) static floatlerp(float a, float b, float t) static floatlerpAngle(float a, float b, float t) static doublelerpUnclamped(double a, double b, double t) static floatlerpUnclamped(float a, float b, float t) static floatmapToRange(float value, float valueMin, float valueMax, float rangeMin, float rangeMax) static bytemaxValue(byte v, byte a, byte b) static bytemaxValue(byte v, byte a, byte b, byte c) static doublemaxValue(double v, double a) static doublemaxValue(double v, double a, double b) static doublemaxValue(double v, double a, double b, double c) static intmaxValue(int v, int a, int b) static doubleminValue(double v, double a, double c) static intminValue(int v, int a, int c) static intpackInt(int x, int z) static longpackLong(int left, int right) static doublepercent(int v, int total) static doublepercentile(long[] sortedData, double percentile) static doublerandomDouble(double min, double max) static floatrandomFloat(float min, float max) static intrandomInt(int min, int max) static org.joml.Vector3drotateVectorYAxis(org.joml.Vector3d vector, double angleRad, boolean clockwise) static org.joml.Vector3drotateVectorYAxis(org.joml.Vector3d vector, int angleDeg, boolean clockwise) static org.joml.Vector3irotateVectorYAxis(org.joml.Vector3i vector, int angleDeg, boolean clockwise) static doubleround(double d, int p) static longsaturatedMultiply(long a, long b) Called to multiply two longs, saturating atLong.MAX_VALUE/Long.MIN_VALUEinstead of overflowing.static floatseededLerp(float a, float b, long seed) Deterministic interpolation within [a, b] from a 64-bit seed.static floatshortAngleDistance(float a, float b) static intsideOfLine(double x, double y, double ax, double ay, double bx, double by) Find the side of the line AB that point P lies on.static intunpackLeft(int packed) static intunpackLeft(long packed) static intunpackRight(int packed) static intunpackRight(long packed) static booleanwithin(double val, double min, double max) static floatwrapAngle(float angle)
-
Field Details
-
EPSILON_DOUBLE
public static final double EPSILON_DOUBLE -
EPSILON_FLOAT
public static final float EPSILON_FLOAT -
ZERO_LENGTH_EPSILON
public static final double ZERO_LENGTH_EPSILONLength-squared below which a vector is treated as degenerate (effectively zero length), used to guard normalization against producing a non-finite result.- See Also:
-
PITCH_EDGE_PADDING
public static float PITCH_EDGE_PADDING
-
-
Method Details
-
abs
public static int abs(int i) -
floor
public static int floor(double d) -
ceil
public static int ceil(double d) -
randomInt
public static int randomInt(int min, int max) -
randomDouble
public static double randomDouble(double min, double max) -
randomFloat
public static float randomFloat(float min, float max) -
round
public static double round(double d, int p) -
within
public static boolean within(double val, double min, double max) -
minValue
public static double minValue(double v, double a, double c) -
minValue
public static int minValue(int v, int a, int c) -
maxValue
public static double maxValue(double v, double a, double b, double c) -
maxValue
public static double maxValue(double v, double a, double b) -
maxValue
public static byte maxValue(byte v, byte a, byte b) -
maxValue
public static byte maxValue(byte v, byte a, byte b, byte c) -
maxValue
public static int maxValue(int v, int a, int b) -
lengthSquared
public static double lengthSquared(double x, double y) -
length
public static double length(double x, double y) -
lengthSquared
public static double lengthSquared(double x, double y, double z) -
length
public static double length(double x, double y, double z) -
maxValue
public static double maxValue(double v, double a) -
clipToZero
public static double clipToZero(double v) -
clipToZero
public static double clipToZero(double v, double epsilon) -
clipToZero
public static float clipToZero(float v) -
clipToZero
public static float clipToZero(float v, float epsilon) -
closeToZero
public static boolean closeToZero(double v) -
closeToZero
public static boolean closeToZero(double v, double epsilon) -
closeToZero
public static boolean closeToZero(float v) -
closeToZero
public static boolean closeToZero(float v, float epsilon) -
clamp
public static double clamp(double v, double min, double max) -
clamp
public static float clamp(float v, float min, float max) -
clamp
public static int clamp(int v, int min, int max) -
clamp
public static long clamp(long v, long min, long max) -
saturatedMultiply
public static long saturatedMultiply(long a, long b) Called to multiply two longs, saturating atLong.MAX_VALUE/Long.MIN_VALUEinstead of overflowing.- Parameters:
a- The first factor.b- The second factor.- Returns:
- the saturated product.
-
getPercentageOf
public static int getPercentageOf(int index, int max) -
percent
public static double percent(int v, int total) -
fastRound
public static int fastRound(float f) -
fastRound
public static long fastRound(double d) -
fastFloor
public static int fastFloor(float f) -
fastFloor
public static long fastFloor(double d) -
fastCeil
public static int fastCeil(float f) -
fastCeil
public static long fastCeil(double d) -
halfFloatToFloat
public static float halfFloatToFloat(int hbits) -
halfFloatFromFloat
public static int halfFloatFromFloat(float fval) -
byteCount
public static int byteCount(int i) -
packInt
public static int packInt(int x, int z) -
unpackLeft
public static int unpackLeft(int packed) -
unpackRight
public static int unpackRight(int packed) -
packLong
public static long packLong(int left, int right) -
unpackLeft
public static int unpackLeft(long packed) -
unpackRight
public static int unpackRight(long packed) -
rotateVectorYAxis
@Nonnull public static org.joml.Vector3i rotateVectorYAxis(@Nonnull org.joml.Vector3i vector, int angleDeg, boolean clockwise) -
rotateVectorYAxis
@Nonnull public static org.joml.Vector3d rotateVectorYAxis(@Nonnull org.joml.Vector3d vector, int angleDeg, boolean clockwise) -
rotateVectorYAxis
@Nonnull public static org.joml.Vector3d rotateVectorYAxis(@Nonnull org.joml.Vector3d vector, double angleRad, boolean clockwise) -
wrapAngle
public static float wrapAngle(float angle) -
lerp
public static float lerp(float a, float b, float t) -
lerpUnclamped
public static float lerpUnclamped(float a, float b, float t) -
lerp
public static double lerp(double a, double b, double t) -
seededLerp
public static float seededLerp(float a, float b, long seed) Deterministic interpolation within [a, b] from a 64-bit seed.Keep byte-for-byte in sync with the client (MathHelper.SeededLerp) so predicted values match the server.
- Parameters:
a- The starting value.b- The ending value.seed- The seed to derive the interpolation factor from.- Returns:
- the interpolated value.
-
lerpUnclamped
public static double lerpUnclamped(double a, double b, double t) -
shortAngleDistance
public static float shortAngleDistance(float a, float b) -
lerpAngle
public static float lerpAngle(float a, float b, float t) -
floorMod
public static double floorMod(double x, double y) -
compareAngle
public static double compareAngle(double a, double b) -
percentile
public static double percentile(@Nonnull long[] sortedData, double percentile) -
distanceToLineSq
public static double distanceToLineSq(double x, double y, double ax, double ay, double bx, double by) Find the distance from point P to the line AB. If the point does not project onto the line then the distance to the nearest end point of the line is returned.- Parameters:
x- The x-coordinate of the point P.y- The y-coordinate of the point P.ax- The x-coordinate of the line point A.ay- The y-coordinate of the line point A.bx- The x-coordinate of the line point B.by- The y-coordinate of the line point B.- Returns:
- The squared distance to the line.
-
distanceToLineSq
public static double distanceToLineSq(double x, double y, double ax, double ay, double bx, double by, double dxAx, double dyAy, double dBxAx, double dByAy) Find the distance from point P to the line AB. If the point does not project onto the line then the distance to the nearest end point of the line is returned.- Parameters:
x- The x-coordinate of the point P.y- The y-coordinate of the point P.ax- The x-coordinate of the line point A.ay- The y-coordinate of the line point A.bx- The x-coordinate of the line point B.by- The y-coordinate of the line point B.dxAx- The x-delta between point P and line point A.dyAy- The y-delta between point P and line point A.dBxAx- The x-delta between point P and line point B.dByAy- The y-delta between point P and line point B.- Returns:
- The squared distance to the line.
-
distanceToInfLineSq
public static double distanceToInfLineSq(double x, double y, double ax, double ay, double bx, double by) Find the distance from point P to its projection onto the infinite line passing through points A and B.- Parameters:
x- The x-coordinate of the point P.y- The y-coordinate of the point P.ax- The x-coordinate of the line point A.ay- The y-coordinate of the line point A.bx- The x-coordinate of the line point B.by- The y-coordinate of the line point B.- Returns:
- The squared distance to the projection point on the line.
-
distanceToInfLineSq
public static double distanceToInfLineSq(double x, double y, double ax, double ay, double dxAx, double dyAy, double dBxAx, double dByAy) Find the distance from point P to its projection onto the infinite line passing through points A and B.- Parameters:
x- The x-coordinate of the point P.y- The y-coordinate of the point P.ax- The x-coordinate of the line point A.ay- The y-coordinate of the line point A.dxAx- The x-delta between point P and line point A.dyAy- The y-delta between point P and line point A.dBxAx- The x-delta between point P and line point B.dByAy- The y-delta between point P and line point B.- Returns:
- The squared distance to the projection point on the line.
-
sideOfLine
public static int sideOfLine(double x, double y, double ax, double ay, double bx, double by) Find the side of the line AB that point P lies on.- Parameters:
x- The x-coordinate of the point P.y- The y-coordinate of the point P.ax- The x-coordinate of the line point A.ay- The y-coordinate of the line point A.bx- The x-coordinate of the line point B.by- The y-coordinate of the line point B.- Returns:
- The side of the line represented either as positive or negative 1.
-
getRotationForHitNormal
-
getNameForHitNormal
-
mapToRange
public static float mapToRange(float value, float valueMin, float valueMax, float rangeMin, float rangeMax)
-