CLASS net/minecraft/class_3532 net/minecraft/util/math/MathHelper COMMENT Contains math-related helper methods. This includes {@code float}-specific extensions COMMENT to {@link Math}, linear interpolation (lerp), and color-related methods. COMMENT COMMENT

Trigonometric functions defined in this class use the "sine table", a pre-calculated COMMENT table of {@code sin(N)} ({@code 0 <= N < pi * 2}). FIELD field_15722 COSINE_OF_ARCSINE_TABLE [D COMMENT Holds values of cos(arcsin(x)): {@code COSINE_OF_ARCSINE_TABLE[i]} is equal to COMMENT {@code Math.cos(Math.arcsin(i / 256.0))}. COMMENT COMMENT

This is used by {@link MathHelper#atan2} to approximate the inverse COMMENT tangent function. FIELD field_15723 MULTIPLY_DE_BRUIJN_BIT_POSITION [I FIELD field_15724 SQUARE_ROOT_OF_TWO F FIELD field_15725 SINE_TABLE [F FIELD field_15726 RANDOM Lnet/minecraft/class_5819; FIELD field_15727 ARCSINE_TABLE [D COMMENT Holds values of arcsin(x): {@code ARCSINE_TABLE[i]} is equal to COMMENT {@code Math.arcsin(i / 256.0)}. COMMENT COMMENT

This is used by {@link MathHelper#atan2} to approximate the inverse COMMENT tangent function. FIELD field_15728 ROUNDER_256THS D COMMENT A constant for rounding a double to the nearest multiple of 1/256. COMMENT COMMENT

When this constant is added to a double that is not too large, then the COMMENT bits of the result's mantissa reflect the original number times 256. COMMENT Consequently, adding this constant and then subtracting it rounds such COMMENT doubles to the nearest multiple of 1/256. COMMENT COMMENT

This is used by {@link MathHelper#atan2} to produce an index into COMMENT {@link MathHelper#ARCSINE_TABLE} and {@link MathHelper#COSINE_OF_ARCSINE_TABLE}. FIELD field_29844 PI F FIELD field_29845 HALF_PI F FIELD field_29846 TAU F COMMENT Tau is equal to {@code 2 * PI}. FIELD field_29847 RADIANS_PER_DEGREE F FIELD field_29848 DEGREES_PER_RADIAN F FIELD field_29849 EPSILON F FIELD field_29853 HALF_PI_RADIANS_SINE_TABLE_INDEX J FIELD field_29856 DEGREES_TO_SINE_TABLE_INDEX F FIELD field_29857 ARCSINE_MACLAURIN_3 D COMMENT Used for the third-order Maclaurin series approximation of the arcsin function, COMMENT x + x^3/6. FIELD field_29859 ARCSINE_TABLE_LENGTH I COMMENT The total number of entries in {@link MathHelper#ARCSINE_TABLE} and COMMENT {@link MathHelper#COSINE_OF_ARCSINE_TABLE}. COMMENT COMMENT

These tables have 257 elements because they store values for multiples of COMMENT 1/256 from 0 to 1, inclusive. METHOD method_15338 wrapDegrees (D)D COMMENT Wraps an angle in degrees to the interval {@code [-180, 180)}. ARG 0 degrees METHOD method_15339 smallestEncompassingPowerOfTwo (I)I ARG 0 value METHOD method_15340 clamp (III)I ARG 0 value ARG 1 min ARG 2 max METHOD method_15341 floorMod (FF)F ARG 0 dividend ARG 1 divisor METHOD method_15342 ceilLog2 (I)I COMMENT {@return ceil(log2({@code value}))} COMMENT COMMENT

The vanilla implementation uses the de Bruijn sequence. COMMENT COMMENT @see Integer#numberOfLeadingZeros(int) ARG 0 value COMMENT the input value METHOD method_15343 parseInt (Ljava/lang/String;I)I ARG 0 string ARG 1 fallback METHOD method_15344 nextFloat (Lnet/minecraft/class_5819;FF)F ARG 0 random ARG 1 min ARG 2 max METHOD method_15345 fastInverseSqrt (D)D COMMENT {@return an approximation of {@code 1 / Math.sqrt(x)}} ARG 0 x METHOD method_15347 approximatelyEquals (FF)Z ARG 0 a ARG 1 b METHOD method_15348 stepTowards (FFF)F COMMENT Steps from {@code from} towards {@code to}, changing the value by at most {@code step}. ARG 0 from ARG 1 to ARG 2 step METHOD method_15349 atan2 (DD)D COMMENT {@return an approximation of {@code Math.atan2(y, x)}} COMMENT COMMENT @implNote This implementation transforms the arguments such that they COMMENT lie in the first quadrant. If {@code y > x}, then {@code x} and {@code y} COMMENT are swapped to minimize the error of the initial approximation. COMMENT {@code x} and {@code y} are normalized, and an initial approximation COMMENT of the result and the sine of the deviation from the true value are COMMENT obtained using the {@link MathHelper#ARCSINE_TABLE} and COMMENT {@link MathHelper#COSINE_OF_ARCSINE_TABLE} lookup tables. The error COMMENT itself is approximated using the third-order Maclaurin series polynomial COMMENT for arcsin. Finally, the implementation undoes any transformations that COMMENT were performed initially. ARG 0 y ARG 2 x METHOD method_15350 clamp (DDD)D ARG 0 value ARG 2 min ARG 4 max METHOD method_15351 floorLog2 (I)I COMMENT {@return floor(log2({@code value}))} COMMENT COMMENT

The vanilla implementation uses the de Bruijn sequence. COMMENT COMMENT @see Integer#numberOfLeadingZeros(int) ARG 0 value COMMENT the input value METHOD method_15352 isPowerOfTwo (I)Z ARG 0 value METHOD method_15353 packRgb (FFF)I ARG 0 r ARG 1 g ARG 2 b METHOD method_15354 idealHash (I)I ARG 0 value METHOD method_15355 sqrt (F)F ARG 0 value METHOD method_15356 angleBetween (FF)F ARG 0 first ARG 1 second METHOD method_15357 floor (D)I ARG 0 value METHOD method_15360 binarySearch (IILjava/util/function/IntPredicate;)I COMMENT Finds the minimum value in {@code [min, max)} that satisfies the COMMENT monotonic {@code predicate}. COMMENT COMMENT

The {@code predicate} must be monotonic, i.e. if for any {@code a}, COMMENT {@code predicate.test(a)} is {@code true}, then for all {@code b > a}, COMMENT {@code predicate.test(b)} must also be {@code true}. COMMENT COMMENT

Examples: COMMENT

COMMENT COMMENT @return the minimum value if such value is found, otherwise {@code max} ARG 0 min COMMENT the minimum value (inclusive) to be tested ARG 1 max COMMENT the maximum value (exclusive) to be tested ARG 2 predicate COMMENT the predicate that returns {@code true} for integers greater than or COMMENT equal to the value to be searched for METHOD method_15362 cos (F)F ARG 0 value METHOD method_15363 clamp (FFF)F ARG 0 value ARG 1 min ARG 2 max METHOD method_15366 nextDouble (Lnet/minecraft/class_5819;DD)D ARG 0 random ARG 1 min ARG 3 max METHOD method_15367 floorMod (DD)D ARG 0 dividend ARG 2 divisor METHOD method_15369 hsvToRgb (FFF)I ARG 0 hue ARG 1 saturation ARG 2 value METHOD method_15370 getLerpProgress (DDD)D COMMENT Gets the fraction of the way that {@code value} is between {@code start} and {@code end}. COMMENT This is the delta value needed to lerp between {@code start} and {@code end} to get {@code value}. COMMENT In other words, {@code getLerpProgress(lerp(delta, start, end), start, end) == delta}. ARG 0 value COMMENT the result of the lerp function ARG 2 start COMMENT the value interpolated from ARG 4 end COMMENT the value interpolated to METHOD method_15371 hashCode (III)J ARG 0 x ARG 1 y ARG 2 z METHOD method_15372 lfloor (D)J ARG 0 value METHOD method_15374 sin (F)F ARG 0 value METHOD method_15375 floor (F)I ARG 0 value METHOD method_15376 ([F)V ARG 0 sineTable METHOD method_15378 randomUuid (Lnet/minecraft/class_5819;)Ljava/util/UUID; ARG 0 random METHOD method_15379 abs (F)F ARG 0 value METHOD method_15381 subtractAngles (FF)F ARG 0 start ARG 1 end METHOD method_15382 abs (I)I ARG 0 value METHOD method_15384 ceil (D)I ARG 0 value METHOD method_15385 fractionalPart (D)D ARG 0 value METHOD method_15386 ceil (F)I ARG 0 value METHOD method_15387 floorMod (II)I ARG 0 dividend ARG 1 divisor METHOD method_15388 stepUnwrappedAngleTowards (FFF)F COMMENT Steps from {@code from} degrees towards {@code to} degrees, changing the value by at most {@code step} degrees. ARG 0 from ARG 1 to ARG 2 step METHOD method_15389 hashCode (Lnet/minecraft/class_2382;)J ARG 0 vec METHOD method_15390 clampedLerp (DDD)D ARG 0 start ARG 2 end ARG 4 delta METHOD method_15391 absMax (DD)D ARG 0 a ARG 2 b METHOD method_15392 wrapDegrees (I)I COMMENT Wraps an angle in degrees to the interval {@code [-180, 180)}. ARG 0 degrees METHOD method_15393 wrapDegrees (F)F COMMENT Wraps an angle in degrees to the interval {@code [-180, 180)}. ARG 0 degrees METHOD method_15394 randomUuid ()Ljava/util/UUID; METHOD method_15395 nextInt (Lnet/minecraft/class_5819;II)I COMMENT {@return a random, uniformly distributed integer value in {@code COMMENT [min, max]}} If the range is empty (i.e. {@code max < min}), it COMMENT returns {@code min}. ARG 0 random ARG 1 min COMMENT the minimum value, inclusive ARG 2 max COMMENT the maximum value, inclusive METHOD method_16435 perlinFade (D)D ARG 0 value METHOD method_16436 lerp (DDD)D ARG 0 delta ARG 2 start ARG 4 end METHOD method_16437 lerp2 (DDDDDD)D COMMENT A two-dimensional lerp between values on the 4 corners of the unit square. Arbitrary values are specified for the corners and the output is interpolated between them. ARG 0 deltaX COMMENT the x-coordinate on the unit square ARG 2 deltaY COMMENT the y-coordinate on the unit square ARG 4 x0y0 COMMENT the output if {@code deltaX} is 0 and {@code deltaY} is 0 ARG 6 x1y0 COMMENT the output if {@code deltaX} is 1 and {@code deltaY} is 0 ARG 8 x0y1 COMMENT the output if {@code deltaX} is 0 and {@code deltaY} is 1 ARG 10 x1y1 COMMENT the output if {@code deltaX} is 1 and {@code deltaY} is 1 METHOD method_16438 lerp3 (DDDDDDDDDDD)D COMMENT A three-dimensional lerp between values on the 8 corners of the unit cube. Arbitrary values are specified for the corners and the output is interpolated between them. ARG 0 deltaX COMMENT the x-coordinate on the unit cube ARG 2 deltaY COMMENT the y-coordinate on the unit cube ARG 4 deltaZ COMMENT the z-coordinate on the unit cube ARG 6 x0y0z0 COMMENT the output if {@code deltaX} is 0, {@code deltaY} is 0 and {@code deltaZ} is 0 ARG 8 x1y0z0 COMMENT the output if {@code deltaX} is 1, {@code deltaY} is 0 and {@code deltaZ} is 0 ARG 10 x0y1z0 COMMENT the output if {@code deltaX} is 0, {@code deltaY} is 1 and {@code deltaZ} is 0 ARG 12 x1y1z0 COMMENT the output if {@code deltaX} is 1, {@code deltaY} is 1 and {@code deltaZ} is 0 ARG 14 x0y0z1 COMMENT the output if {@code deltaX} is 0, {@code deltaY} is 0 and {@code deltaZ} is 1 ARG 16 x1y0z1 COMMENT the output if {@code deltaX} is 1, {@code deltaY} is 0 and {@code deltaZ} is 1 ARG 18 x0y1z1 COMMENT the output if {@code deltaX} is 0, {@code deltaY} is 1 and {@code deltaZ} is 1 ARG 20 x1y1z1 COMMENT the output if {@code deltaX} is 1, {@code deltaY} is 1 and {@code deltaZ} is 1 METHOD method_16439 lerp (FFF)F ARG 0 delta ARG 1 start ARG 2 end METHOD method_17821 lerpAngleDegrees (FFF)F ARG 0 delta ARG 1 start ARG 2 end METHOD method_17822 sign (D)I ARG 0 value METHOD method_20306 clampAngle (FFF)F COMMENT Clamps {@code value}, as an angle, between {@code mean - delta} and {@code COMMENT mean + delta} degrees. COMMENT COMMENT @return the clamped {@code value} ARG 0 value COMMENT the value to clamp ARG 1 mean COMMENT the mean value of the clamp angle range ARG 2 delta COMMENT the maximum difference allowed from the mean, must not be negative METHOD method_20390 approximatelyEquals (DD)Z ARG 0 a ARG 2 b METHOD method_22450 fractionalPart (F)F ARG 0 value METHOD method_23278 fastInverseCbrt (F)F COMMENT {@return an approximation of {@code 1 / Math.cbrt(x)}} ARG 0 x METHOD method_24504 wrap (FF)F ARG 0 value ARG 1 maxDeviation METHOD method_27285 square (F)F ARG 0 n METHOD method_28139 roundUpToMultiple (II)I COMMENT Returns a value farther than or as far as {@code value} from zero that COMMENT is a multiple of {@code divisor}. ARG 0 value ARG 1 divisor METHOD method_32750 nextBetween (Lnet/minecraft/class_5819;FF)F ARG 0 random ARG 1 min ARG 2 max METHOD method_32751 nextBetween (Lnet/minecraft/class_5819;II)I COMMENT {@return a random, uniformly distributed integer value in {@code COMMENT [min, max]}} COMMENT COMMENT @throws IllegalArgumentException if the range is empty (i.e. {@code COMMENT max < min}) ARG 0 random ARG 1 min COMMENT the minimum value, inclusive ARG 2 max COMMENT the maximum value, inclusive METHOD method_32854 clampedMap (DDDDD)D COMMENT Linearly maps a value from one number range to another COMMENT and clamps the result. COMMENT COMMENT @return the mapped value, clamped between {@code newStart} and {@code newEnd} COMMENT @see #map(double, double, double, double, double) the unclamped variant ARG 0 value COMMENT the input value ARG 2 oldStart COMMENT the starting value of the original range ARG 4 oldEnd COMMENT the end value of the original range ARG 6 newStart COMMENT the starting value of the new range ARG 8 newEnd COMMENT the end value of the new range METHOD method_32855 nextGaussian (Lnet/minecraft/class_5819;FF)F ARG 0 random ARG 1 mean ARG 2 deviation METHOD method_33722 map (DDDDD)D COMMENT Linearly maps a value from one number range to another, unclamped. COMMENT COMMENT

For the return value {@code result}, {@code getLerpProgress(value, oldStart, oldEnd)} COMMENT is approximately equal to {@code getLerpProgress(result, newStart, newEnd)} COMMENT (accounting for floating point errors). COMMENT COMMENT @return the mapped value ARG 0 value COMMENT the input value ARG 2 oldStart COMMENT the starting value of the original range ARG 4 oldEnd COMMENT the end value of the original range ARG 6 newStart COMMENT the starting value of the new range ARG 8 newEnd COMMENT the end value of the new range METHOD method_33723 square (D)D ARG 0 n METHOD method_33825 magnitude (DDD)D ARG 0 a ARG 2 b ARG 4 c METHOD method_34945 (Lnet/minecraft/class_243;Lnet/minecraft/class_243;Lnet/minecraft/class_238;)Z ARG 0 origin ARG 1 direction ARG 2 box METHOD method_34954 square (I)I ARG 0 n METHOD method_34956 perlinFadeDerivative (D)D ARG 0 value METHOD method_37166 clampedLerp (FFF)F ARG 0 start ARG 1 end ARG 2 delta METHOD method_37958 clampedMap (FFFFF)F COMMENT Linearly maps a value from one number range to another COMMENT and clamps the result. COMMENT COMMENT @return the mapped value, clamped between {@code newStart} and {@code newEnd} COMMENT @see #map(float, float, float, float, float) the unclamped variant ARG 0 value COMMENT the input value ARG 1 oldStart COMMENT the starting value of the original range ARG 2 oldEnd COMMENT the end value of the original range ARG 3 newStart COMMENT the starting value of the new range ARG 4 newEnd COMMENT the end value of the new range METHOD method_37959 map (FFFFF)F COMMENT Linearly maps a value from one number range to another, unclamped. COMMENT COMMENT

For the return value {@code result}, {@code getLerpProgress(value, oldStart, oldEnd)} COMMENT is approximately equal to {@code getLerpProgress(result, newStart, newEnd)} COMMENT (accounting for floating point errors). COMMENT COMMENT @return the mapped value ARG 0 value COMMENT the input value ARG 1 oldStart COMMENT the starting value of the original range ARG 2 oldEnd COMMENT the end value of the original range ARG 3 newStart COMMENT the starting value of the new range ARG 4 newEnd COMMENT the end value of the new range METHOD method_37960 getLerpProgress (FFF)F ARG 0 value ARG 1 start ARG 2 end METHOD method_38652 square (J)J ARG 0 n METHOD method_38788 ceilDiv (II)I ARG 0 a ARG 1 b METHOD method_38961 roundDownToMultiple (DI)I COMMENT {@return {@code a} rounded down to the nearest multiple of {@code b}} ARG 0 a ARG 2 b METHOD method_39241 hypot (DD)D ARG 0 a ARG 2 b METHOD method_41189 squaredHypot (DD)D ARG 0 a ARG 2 b METHOD method_41190 squaredMagnitude (DDD)D ARG 0 a ARG 2 b ARG 4 c METHOD method_41303 catmullRom (FFFFF)F COMMENT Interpolates a point on a Catmull-Rom Spline. This spline has a property that if there are two COMMENT splines with arguments {@code p0, p1, p2, p3} and {@code p1, p2, p3, p4}, the resulting curve COMMENT will have a continuous first derivative at {@code p2}, where the two input curves connect. For COMMENT higher-dimensional curves, the interpolation on the curve is done component-wise: for COMMENT inputs {@code delta, (p0x, p0y), (p1x, p1y), (p2x, p2y), (p3x, p3y)}, the output is COMMENT {@code (catmullRom(delta, p0x, p1x, p2x, p3x), catmullRom(delta, p0y, p1y, p2y, p3y))}. COMMENT COMMENT @see Cubic Hermite spline (Catmull–Rom spline) ARG 0 delta COMMENT the progress along the interpolation ARG 1 p0 COMMENT the previous data point to assist in curve-smoothing ARG 2 p1 COMMENT the output if {@code delta} is 0 ARG 3 p2 COMMENT the output if {@code delta} is 1 ARG 4 p3 COMMENT the next data point to assist in curve-smoothing METHOD method_42117 stream (IIII)Ljava/util/stream/IntStream; ARG 0 seed ARG 1 lowerBound ARG 2 upperBound ARG 3 steps METHOD method_42118 (IIIII)I ARG 4 i METHOD method_42119 (IIII)Z ARG 3 i METHOD method_42120 stream (III)Ljava/util/stream/IntStream; ARG 0 seed ARG 1 lowerBound ARG 2 upperBound METHOD method_48116 floorDiv (II)I ARG 0 dividend ARG 1 divisor METHOD method_48117 isMultipleOf (II)Z ARG 0 a ARG 1 b METHOD method_48118 inverseSqrt (D)D ARG 0 x METHOD method_48119 inverseSqrt (F)F ARG 0 x METHOD method_48781 lerp (FII)I ARG 0 delta ARG 1 start ARG 2 end