Package net.frozenblock.lib.math.api
Class AdvancedMath
java.lang.Object
net.frozenblock.lib.math.api.AdvancedMath
Adds more math operations.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcombinations(int n, int r) static doublecutCos(double value, double offset, boolean inverse) static intfactorial(int n) static doublegetAngleBetweenXZ(@NotNull net.minecraft.world.phys.Vec3 posA, @NotNull net.minecraft.world.phys.Vec3 posB) static doublegetAngleFromOriginXZ(@NotNull net.minecraft.world.phys.Vec3 pos) static intgreatestCommonDivisor(int a, int b) Calculates the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.static net.minecraft.core.BlockPosoffset(net.minecraft.core.BlockPos pos, @NotNull net.minecraft.core.Direction dir, int a) static net.minecraft.core.BlockPosoffset(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir) static intpermutations(int n, int r) static @NotNull net.minecraft.util.RandomSourcerandom()static @NotNull net.minecraft.core.DirectionrandomDir(net.minecraft.core.Direction.Axis axis) static doublestatic floatrange(float min, float max, float number) static @NotNull net.minecraft.world.phys.Vec3rotateAboutX(@NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle) static @NotNull net.minecraft.world.phys.Vec3rotateAboutXZ(@NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle) static double @Nullable []solveQuadraticEquation(double a, double b, double c) Solves a quadratic equation of the form ax^2 + bx + c = 0.static booleansquareBetween(int x, int z, int between1, int between2) static intwaterLevelReduce(int value) static intwaterToHollowedProperty(int value)
-
Constructor Details
-
AdvancedMath
public AdvancedMath()
-
-
Method Details
-
random
@Contract(" -> new") @NotNull public static @NotNull net.minecraft.util.RandomSource random() -
range
public static float range(float min, float max, float number) -
randomPosNeg
public static double randomPosNeg() -
squareBetween
public static boolean squareBetween(int x, int z, int between1, int between2) -
offset
public static net.minecraft.core.BlockPos offset(net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.core.Direction dir, int a) -
offset
public static net.minecraft.core.BlockPos offset(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir) -
waterToHollowedProperty
public static int waterToHollowedProperty(int value) -
waterLevelReduce
public static int waterLevelReduce(int value) -
cutCos
public static double cutCos(double value, double offset, boolean inverse) -
factorial
public static int factorial(int n) -
permutations
public static int permutations(int n, int r) -
combinations
public static int combinations(int n, int r) -
solveQuadraticEquation
public static double @Nullable [] solveQuadraticEquation(double a, double b, double c) Solves a quadratic equation of the form ax^2 + bx + c = 0.- Parameters:
a- the coefficient of x^2 (must be non-zero)b- the coefficient of xc- the constant term- Returns:
- an array containing the real roots of the equation, or null if no real roots exist
- Throws:
IllegalArgumentException- if a is zero
-
greatestCommonDivisor
public static int greatestCommonDivisor(int a, int b) Calculates the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.- Parameters:
a- the first numberb- the second number- Returns:
- the GCD of a and b
-
randomDir
@NotNull public static @NotNull net.minecraft.core.Direction randomDir(@NotNull net.minecraft.core.Direction.Axis axis) - Parameters:
axis- The axis that should be used to determine a random direction.- Returns:
- A random Direction on a specific Direction.Axis.
-
rotateAboutXZ
@NotNull public static @NotNull net.minecraft.world.phys.Vec3 rotateAboutXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle) -
rotateAboutX
@NotNull public static @NotNull net.minecraft.world.phys.Vec3 rotateAboutX(@NotNull @NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle) -
getAngleFromOriginXZ
@Contract(pure=true) public static double getAngleFromOriginXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 pos) -
getAngleBetweenXZ
public static double getAngleBetweenXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 posA, @NotNull @NotNull net.minecraft.world.phys.Vec3 posB)
-