Mth.java

net.minecraft.util.Mth

信息

  • 全限定名:net.minecraft.util.Mth
  • 类型:public class
  • 包:net.minecraft.util
  • 源码路径:src/main/java/net/minecraft/util/Mth.java
  • 起始行号:L15
  • 职责:

    TODO

字段/常量

  • UUID_VERSION

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L16
    • 说明:

      TODO

  • UUID_VERSION_TYPE_4

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L17
    • 说明:

      TODO

  • UUID_VARIANT

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • UUID_VARIANT_2

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L19
    • 说明:

      TODO

  • PI

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L20
    • 说明:

      TODO

  • HALF_PI

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L21
    • 说明:

      TODO

  • TWO_PI

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L22
    • 说明:

      TODO

  • DEG_TO_RAD

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L23
    • 说明:

      TODO

  • RAD_TO_DEG

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L24
    • 说明:

      TODO

  • EPSILON

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L25
    • 说明:

      TODO

  • SQRT_OF_TWO

    • 类型: float
    • 修饰符: public static final
    • 源码定位: L26
    • 说明:

      TODO

  • Y_AXIS

    • 类型: Vector3f
    • 修饰符: public static final
    • 源码定位: L27
    • 说明:

      TODO

  • X_AXIS

    • 类型: Vector3f
    • 修饰符: public static final
    • 源码定位: L28
    • 说明:

      TODO

  • Z_AXIS

    • 类型: Vector3f
    • 修饰符: public static final
    • 源码定位: L29
    • 说明:

      TODO

  • SIN_QUANTIZATION

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L30
    • 说明:

      TODO

  • SIN_MASK

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L31
    • 说明:

      TODO

  • COS_OFFSET

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L32
    • 说明:

      TODO

  • SIN_SCALE

    • 类型: double
    • 修饰符: private static final
    • 源码定位: L33
    • 说明:

      TODO

  • SIN

    • 类型: float[]
    • 修饰符: private static final
    • 源码定位: L34
    • 说明:

      TODO

  • MULTIPLY_DE_BRUIJN_BIT_POSITION

    • 类型: int[]
    • 修饰符: private static final
    • 源码定位: L39
    • 说明:

      TODO

  • ONE_SIXTH

    • 类型: double
    • 修饰符: private static final
    • 源码定位: L42
    • 说明:

      TODO

  • FRAC_EXP

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L43
    • 说明:

      TODO

  • LUT_SIZE

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L44
    • 说明:

      TODO

  • FRAC_BIAS

    • 类型: double
    • 修饰符: private static final
    • 源码定位: L45
    • 说明:

      TODO

  • ASIN_TAB

    • 类型: double[]
    • 修饰符: private static final
    • 源码定位: L46
    • 说明:

      TODO

  • COS_TAB

    • 类型: double[]
    • 修饰符: private static final
    • 源码定位: L47
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static float sin(double i) @ L49

  • 方法名:sin
  • 源码定位:L49
  • 返回类型:float
  • 修饰符:public static

参数:

  • i: double

说明:

TODO

public static float cos(double i) @ L53

  • 方法名:cos
  • 源码定位:L53
  • 返回类型:float
  • 修饰符:public static

参数:

  • i: double

说明:

TODO

public static float sqrt(float x) @ L57

  • 方法名:sqrt
  • 源码定位:L57
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float

说明:

TODO

public static int floor(float v) @ L61

  • 方法名:floor
  • 源码定位:L61
  • 返回类型:int
  • 修饰符:public static

参数:

  • v: float

说明:

TODO

public static int floor(double v) @ L65

  • 方法名:floor
  • 源码定位:L65
  • 返回类型:int
  • 修饰符:public static

参数:

  • v: double

说明:

TODO

public static long lfloor(double v) @ L69

  • 方法名:lfloor
  • 源码定位:L69
  • 返回类型:long
  • 修饰符:public static

参数:

  • v: double

说明:

TODO

public static float abs(float v) @ L73

  • 方法名:abs
  • 源码定位:L73
  • 返回类型:float
  • 修饰符:public static

参数:

  • v: float

说明:

TODO

public static int abs(int v) @ L77

  • 方法名:abs
  • 源码定位:L77
  • 返回类型:int
  • 修饰符:public static

参数:

  • v: int

说明:

TODO

public static int ceil(float v) @ L81

  • 方法名:ceil
  • 源码定位:L81
  • 返回类型:int
  • 修饰符:public static

参数:

  • v: float

说明:

TODO

public static int ceil(double v) @ L85

  • 方法名:ceil
  • 源码定位:L85
  • 返回类型:int
  • 修饰符:public static

参数:

  • v: double

说明:

TODO

public static long ceilLong(double v) @ L89

  • 方法名:ceilLong
  • 源码定位:L89
  • 返回类型:long
  • 修饰符:public static

参数:

  • v: double

说明:

TODO

public static int clamp(int value, int min, int max) @ L93

  • 方法名:clamp
  • 源码定位:L93
  • 返回类型:int
  • 修饰符:public static

参数:

  • value: int
  • min: int
  • max: int

说明:

TODO

public static long clamp(long value, long min, long max) @ L97

  • 方法名:clamp
  • 源码定位:L97
  • 返回类型:long
  • 修饰符:public static

参数:

  • value: long
  • min: long
  • max: long

说明:

TODO

public static float clamp(float value, float min, float max) @ L101

  • 方法名:clamp
  • 源码定位:L101
  • 返回类型:float
  • 修饰符:public static

参数:

  • value: float
  • min: float
  • max: float

说明:

TODO

public static double clamp(double value, double min, double max) @ L105

  • 方法名:clamp
  • 源码定位:L105
  • 返回类型:double
  • 修饰符:public static

参数:

  • value: double
  • min: double
  • max: double

说明:

TODO

public static double clampedLerp(double factor, double min, double max) @ L109

  • 方法名:clampedLerp
  • 源码定位:L109
  • 返回类型:double
  • 修饰符:public static

参数:

  • factor: double
  • min: double
  • max: double

说明:

TODO

public static float clampedLerp(float factor, float min, float max) @ L117

  • 方法名:clampedLerp
  • 源码定位:L117
  • 返回类型:float
  • 修饰符:public static

参数:

  • factor: float
  • min: float
  • max: float

说明:

TODO

public static int absMax(int a, int b) @ L125

  • 方法名:absMax
  • 源码定位:L125
  • 返回类型:int
  • 修饰符:public static

参数:

  • a: int
  • b: int

说明:

TODO

public static float absMax(float a, float b) @ L129

  • 方法名:absMax
  • 源码定位:L129
  • 返回类型:float
  • 修饰符:public static

参数:

  • a: float
  • b: float

说明:

TODO

public static double absMax(double a, double b) @ L133

  • 方法名:absMax
  • 源码定位:L133
  • 返回类型:double
  • 修饰符:public static

参数:

  • a: double
  • b: double

说明:

TODO

public static int chessboardDistance(int x0, int z0, int x1, int z1) @ L137

  • 方法名:chessboardDistance
  • 源码定位:L137
  • 返回类型:int
  • 修饰符:public static

参数:

  • x0: int
  • z0: int
  • x1: int
  • z1: int

说明:

TODO

public static int floorDiv(int a, int b) @ L141

  • 方法名:floorDiv
  • 源码定位:L141
  • 返回类型:int
  • 修饰符:public static

参数:

  • a: int
  • b: int

说明:

TODO

public static int nextInt(RandomSource random, int minInclusive, int maxInclusive) @ L145

  • 方法名:nextInt
  • 源码定位:L145
  • 返回类型:int
  • 修饰符:public static

参数:

  • random: RandomSource
  • minInclusive: int
  • maxInclusive: int

说明:

TODO

public static float nextFloat(RandomSource random, float min, float max) @ L149

  • 方法名:nextFloat
  • 源码定位:L149
  • 返回类型:float
  • 修饰符:public static

参数:

  • random: RandomSource
  • min: float
  • max: float

说明:

TODO

public static double nextDouble(RandomSource random, double min, double max) @ L153

  • 方法名:nextDouble
  • 源码定位:L153
  • 返回类型:double
  • 修饰符:public static

参数:

  • random: RandomSource
  • min: double
  • max: double

说明:

TODO

public static boolean equal(float a, float b) @ L157

  • 方法名:equal
  • 源码定位:L157
  • 返回类型:boolean
  • 修饰符:public static

参数:

  • a: float
  • b: float

说明:

TODO

public static boolean equal(double a, double b) @ L161

  • 方法名:equal
  • 源码定位:L161
  • 返回类型:boolean
  • 修饰符:public static

参数:

  • a: double
  • b: double

说明:

TODO

public static int positiveModulo(int input, int mod) @ L165

  • 方法名:positiveModulo
  • 源码定位:L165
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int
  • mod: int

说明:

TODO

public static float positiveModulo(float input, float mod) @ L169

  • 方法名:positiveModulo
  • 源码定位:L169
  • 返回类型:float
  • 修饰符:public static

参数:

  • input: float
  • mod: float

说明:

TODO

public static double positiveModulo(double input, double mod) @ L173

  • 方法名:positiveModulo
  • 源码定位:L173
  • 返回类型:double
  • 修饰符:public static

参数:

  • input: double
  • mod: double

说明:

TODO

public static boolean isMultipleOf(int dividend, int divisor) @ L177

  • 方法名:isMultipleOf
  • 源码定位:L177
  • 返回类型:boolean
  • 修饰符:public static

参数:

  • dividend: int
  • divisor: int

说明:

TODO

public static byte packDegrees(float angle) @ L181

  • 方法名:packDegrees
  • 源码定位:L181
  • 返回类型:byte
  • 修饰符:public static

参数:

  • angle: float

说明:

TODO

public static float unpackDegrees(byte rot) @ L185

  • 方法名:unpackDegrees
  • 源码定位:L185
  • 返回类型:float
  • 修饰符:public static

参数:

  • rot: byte

说明:

TODO

public static int wrapDegrees(int angle) @ L189

  • 方法名:wrapDegrees
  • 源码定位:L189
  • 返回类型:int
  • 修饰符:public static

参数:

  • angle: int

说明:

TODO

public static float wrapDegrees(long angle) @ L202

  • 方法名:wrapDegrees
  • 源码定位:L202
  • 返回类型:float
  • 修饰符:public static

参数:

  • angle: long

说明:

TODO

public static float wrapDegrees(float angle) @ L215

  • 方法名:wrapDegrees
  • 源码定位:L215
  • 返回类型:float
  • 修饰符:public static

参数:

  • angle: float

说明:

TODO

public static double wrapDegrees(double angle) @ L228

  • 方法名:wrapDegrees
  • 源码定位:L228
  • 返回类型:double
  • 修饰符:public static

参数:

  • angle: double

说明:

TODO

public static float degreesDifference(float fromAngle, float toAngle) @ L241

  • 方法名:degreesDifference
  • 源码定位:L241
  • 返回类型:float
  • 修饰符:public static

参数:

  • fromAngle: float
  • toAngle: float

说明:

TODO

public static float degreesDifferenceAbs(float angleA, float angleB) @ L245

  • 方法名:degreesDifferenceAbs
  • 源码定位:L245
  • 返回类型:float
  • 修饰符:public static

参数:

  • angleA: float
  • angleB: float

说明:

TODO

public static float rotateIfNecessary(float baseAngle, float targetAngle, float maxAngleDiff) @ L249

  • 方法名:rotateIfNecessary
  • 源码定位:L249
  • 返回类型:float
  • 修饰符:public static

参数:

  • baseAngle: float
  • targetAngle: float
  • maxAngleDiff: float

说明:

TODO

public static float approach(float current, float target, float increment) @ L255

  • 方法名:approach
  • 源码定位:L255
  • 返回类型:float
  • 修饰符:public static

参数:

  • current: float
  • target: float
  • increment: float

说明:

TODO

public static float approachDegrees(float current, float target, float increment) @ L260

  • 方法名:approachDegrees
  • 源码定位:L260
  • 返回类型:float
  • 修饰符:public static

参数:

  • current: float
  • target: float
  • increment: float

说明:

TODO

public static int getInt(String input, int def) @ L265

  • 方法名:getInt
  • 源码定位:L265
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: String
  • def: int

说明:

TODO

public static int smallestEncompassingPowerOfTwo(int input) @ L269

  • 方法名:smallestEncompassingPowerOfTwo
  • 源码定位:L269
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int

说明:

TODO

public static int smallestSquareSide(int itemCount) @ L279

  • 方法名:smallestSquareSide
  • 源码定位:L279
  • 返回类型:int
  • 修饰符:public static

参数:

  • itemCount: int

说明:

TODO

public static boolean isPowerOfTwo(int input) @ L287

  • 方法名:isPowerOfTwo
  • 源码定位:L287
  • 返回类型:boolean
  • 修饰符:public static

参数:

  • input: int

说明:

TODO

public static int ceillog2(int input) @ L291

  • 方法名:ceillog2
  • 源码定位:L291
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int

说明:

TODO

public static int log2(int input) @ L296

  • 方法名:log2
  • 源码定位:L296
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int

说明:

TODO

public static float frac(float num) @ L300

  • 方法名:frac
  • 源码定位:L300
  • 返回类型:float
  • 修饰符:public static

参数:

  • num: float

说明:

TODO

public static double frac(double num) @ L304

  • 方法名:frac
  • 源码定位:L304
  • 返回类型:double
  • 修饰符:public static

参数:

  • num: double

说明:

TODO

public static long getSeed(Vec3i vec) @ L308

  • 方法名:getSeed
  • 源码定位:L308
  • 返回类型:long
  • 修饰符:public static

参数:

  • vec: Vec3i

说明:

TODO

public static long getSeed(int x, int y, int z) @ L313

  • 方法名:getSeed
  • 源码定位:L313
  • 返回类型:long
  • 修饰符:public static

参数:

  • x: int
  • y: int
  • z: int

说明:

TODO

public static UUID createInsecureUUID(RandomSource random) @ L320

  • 方法名:createInsecureUUID
  • 源码定位:L320
  • 返回类型:UUID
  • 修饰符:public static

参数:

  • random: RandomSource

说明:

TODO

public static double inverseLerp(double value, double min, double max) @ L326

  • 方法名:inverseLerp
  • 源码定位:L326
  • 返回类型:double
  • 修饰符:public static

参数:

  • value: double
  • min: double
  • max: double

说明:

TODO

public static float inverseLerp(float value, float min, float max) @ L330

  • 方法名:inverseLerp
  • 源码定位:L330
  • 返回类型:float
  • 修饰符:public static

参数:

  • value: float
  • min: float
  • max: float

说明:

TODO

public static boolean rayIntersectsAABB(Vec3 rayStart, Vec3 rayDir, AABB aabb) @ L334

  • 方法名:rayIntersectsAABB
  • 源码定位:L334
  • 返回类型:boolean
  • 修饰符:public static

参数:

  • rayStart: Vec3
  • rayDir: Vec3
  • aabb: AABB

说明:

TODO

public static double atan2(double y, double x) @ L373

  • 方法名:atan2
  • 源码定位:L373
  • 返回类型:double
  • 修饰符:public static

参数:

  • y: double
  • x: double

说明:

TODO

public static float invSqrt(float x) @ L422

  • 方法名:invSqrt
  • 源码定位:L422
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float

说明:

TODO

public static double invSqrt(double x) @ L426

  • 方法名:invSqrt
  • 源码定位:L426
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double

说明:

TODO

public static double fastInvSqrt(double x) @ L430

  • 方法名:fastInvSqrt
  • 源码定位:L430
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double

说明:

TODO

public static float fastInvCubeRoot(float x) @ L439

  • 方法名:fastInvCubeRoot
  • 源码定位:L439
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float

说明:

TODO

public static int hsvToRgb(float hue, float saturation, float value) @ L447

  • 方法名:hsvToRgb
  • 源码定位:L447
  • 返回类型:int
  • 修饰符:public static

参数:

  • hue: float
  • saturation: float
  • value: float

说明:

TODO

public static int hsvToArgb(float hue, float saturation, float value, int alpha) @ L451

  • 方法名:hsvToArgb
  • 源码定位:L451
  • 返回类型:int
  • 修饰符:public static

参数:

  • hue: float
  • saturation: float
  • value: float
  • alpha: int

说明:

TODO

public static int murmurHash3Mixer(int hash) @ L498

  • 方法名:murmurHash3Mixer
  • 源码定位:L498
  • 返回类型:int
  • 修饰符:public static

参数:

  • hash: int

说明:

TODO

public static int binarySearch(int from, int to, IntPredicate condition) @ L506

  • 方法名:binarySearch
  • 源码定位:L506
  • 返回类型:int
  • 修饰符:public static

参数:

  • from: int
  • to: int
  • condition: IntPredicate

说明:

TODO

public static int lerpInt(float alpha1, int p0, int p1) @ L523

  • 方法名:lerpInt
  • 源码定位:L523
  • 返回类型:int
  • 修饰符:public static

参数:

  • alpha1: float
  • p0: int
  • p1: int

说明:

TODO

public static int lerpDiscrete(float alpha1, int p0, int p1) @ L527

  • 方法名:lerpDiscrete
  • 源码定位:L527
  • 返回类型:int
  • 修饰符:public static

参数:

  • alpha1: float
  • p0: int
  • p1: int

说明:

TODO

public static float lerp(float alpha1, float p0, float p1) @ L532

  • 方法名:lerp
  • 源码定位:L532
  • 返回类型:float
  • 修饰符:public static

参数:

  • alpha1: float
  • p0: float
  • p1: float

说明:

TODO

public static Vec3 lerp(double alpha, Vec3 p1, Vec3 p2) @ L536

  • 方法名:lerp
  • 源码定位:L536
  • 返回类型:Vec3
  • 修饰符:public static

参数:

  • alpha: double
  • p1: Vec3
  • p2: Vec3

说明:

TODO

public static double lerp(double alpha1, double p0, double p1) @ L540

  • 方法名:lerp
  • 源码定位:L540
  • 返回类型:double
  • 修饰符:public static

参数:

  • alpha1: double
  • p0: double
  • p1: double

说明:

TODO

public static double lerp2(double alpha1, double alpha2, double x00, double x10, double x01, double x11) @ L544

  • 方法名:lerp2
  • 源码定位:L544
  • 返回类型:double
  • 修饰符:public static

参数:

  • alpha1: double
  • alpha2: double
  • x00: double
  • x10: double
  • x01: double
  • x11: double

说明:

TODO

public static double lerp3(double alpha1, double alpha2, double alpha3, double x000, double x100, double x010, double x110, double x001, double x101, double x011, double x111) @ L548

  • 方法名:lerp3
  • 源码定位:L548
  • 返回类型:double
  • 修饰符:public static

参数:

  • alpha1: double
  • alpha2: double
  • alpha3: double
  • x000: double
  • x100: double
  • x010: double
  • x110: double
  • x001: double
  • x101: double
  • x011: double
  • x111: double

说明:

TODO

public static float catmullrom(float alpha, float p0, float p1, float p2, float p3) @ L554

  • 方法名:catmullrom
  • 源码定位:L554
  • 返回类型:float
  • 修饰符:public static

参数:

  • alpha: float
  • p0: float
  • p1: float
  • p2: float
  • p3: float

说明:

TODO

public static double smoothstep(double x) @ L564

  • 方法名:smoothstep
  • 源码定位:L564
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double

说明:

TODO

public static double smoothstepDerivative(double x) @ L568

  • 方法名:smoothstepDerivative
  • 源码定位:L568
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double

说明:

TODO

public static int sign(double number) @ L572

  • 方法名:sign
  • 源码定位:L572
  • 返回类型:int
  • 修饰符:public static

参数:

  • number: double

说明:

TODO

public static float rotLerp(float a, float from, float to) @ L580

  • 方法名:rotLerp
  • 源码定位:L580
  • 返回类型:float
  • 修饰符:public static

参数:

  • a: float
  • from: float
  • to: float

说明:

TODO

public static double rotLerp(double a, double from, double to) @ L584

  • 方法名:rotLerp
  • 源码定位:L584
  • 返回类型:double
  • 修饰符:public static

参数:

  • a: double
  • from: double
  • to: double

说明:

TODO

public static float rotLerpRad(float a, float from, float to) @ L588

  • 方法名:rotLerpRad
  • 源码定位:L588
  • 返回类型:float
  • 修饰符:public static

参数:

  • a: float
  • from: float
  • to: float

说明:

TODO

public static float triangleWave(float index, float period) @ L602

  • 方法名:triangleWave
  • 源码定位:L602
  • 返回类型:float
  • 修饰符:public static

参数:

  • index: float
  • period: float

说明:

TODO

public static float square(float x) @ L606

  • 方法名:square
  • 源码定位:L606
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float

说明:

TODO

public static float cube(float x) @ L610

  • 方法名:cube
  • 源码定位:L610
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float

说明:

TODO

public static double square(double x) @ L614

  • 方法名:square
  • 源码定位:L614
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double

说明:

TODO

public static int square(int x) @ L618

  • 方法名:square
  • 源码定位:L618
  • 返回类型:int
  • 修饰符:public static

参数:

  • x: int

说明:

TODO

public static long square(long x) @ L622

  • 方法名:square
  • 源码定位:L622
  • 返回类型:long
  • 修饰符:public static

参数:

  • x: long

说明:

TODO

public static double clampedMap(double value, double fromMin, double fromMax, double toMin, double toMax) @ L626

  • 方法名:clampedMap
  • 源码定位:L626
  • 返回类型:double
  • 修饰符:public static

参数:

  • value: double
  • fromMin: double
  • fromMax: double
  • toMin: double
  • toMax: double

说明:

TODO

public static float clampedMap(float value, float fromMin, float fromMax, float toMin, float toMax) @ L630

  • 方法名:clampedMap
  • 源码定位:L630
  • 返回类型:float
  • 修饰符:public static

参数:

  • value: float
  • fromMin: float
  • fromMax: float
  • toMin: float
  • toMax: float

说明:

TODO

public static double map(double value, double fromMin, double fromMax, double toMin, double toMax) @ L634

  • 方法名:map
  • 源码定位:L634
  • 返回类型:double
  • 修饰符:public static

参数:

  • value: double
  • fromMin: double
  • fromMax: double
  • toMin: double
  • toMax: double

说明:

TODO

public static float map(float value, float fromMin, float fromMax, float toMin, float toMax) @ L638

  • 方法名:map
  • 源码定位:L638
  • 返回类型:float
  • 修饰符:public static

参数:

  • value: float
  • fromMin: float
  • fromMax: float
  • toMin: float
  • toMax: float

说明:

TODO

public static double wobble(double coord) @ L642

  • 方法名:wobble
  • 源码定位:L642
  • 返回类型:double
  • 修饰符:public static

参数:

  • coord: double

说明:

TODO

public static int roundToward(int input, int multiple) @ L646

  • 方法名:roundToward
  • 源码定位:L646
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int
  • multiple: int

说明:

TODO

public static int positiveCeilDiv(int input, int divisor) @ L650

  • 方法名:positiveCeilDiv
  • 源码定位:L650
  • 返回类型:int
  • 修饰符:public static

参数:

  • input: int
  • divisor: int

说明:

TODO

public static int randomBetweenInclusive(RandomSource random, int min, int maxInclusive) @ L654

  • 方法名:randomBetweenInclusive
  • 源码定位:L654
  • 返回类型:int
  • 修饰符:public static

参数:

  • random: RandomSource
  • min: int
  • maxInclusive: int

说明:

TODO

public static float randomBetween(RandomSource random, float min, float maxExclusive) @ L658

  • 方法名:randomBetween
  • 源码定位:L658
  • 返回类型:float
  • 修饰符:public static

参数:

  • random: RandomSource
  • min: float
  • maxExclusive: float

说明:

TODO

public static float normal(RandomSource random, float mean, float deviation) @ L662

  • 方法名:normal
  • 源码定位:L662
  • 返回类型:float
  • 修饰符:public static

参数:

  • random: RandomSource
  • mean: float
  • deviation: float

说明:

TODO

public static double lengthSquared(double x, double y) @ L666

  • 方法名:lengthSquared
  • 源码定位:L666
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double
  • y: double

说明:

TODO

public static double length(double x, double y) @ L670

  • 方法名:length
  • 源码定位:L670
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double
  • y: double

说明:

TODO

public static float length(float x, float y) @ L674

  • 方法名:length
  • 源码定位:L674
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float
  • y: float

说明:

TODO

public static double lengthSquared(double x, double y, double z) @ L678

  • 方法名:lengthSquared
  • 源码定位:L678
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double
  • y: double
  • z: double

说明:

TODO

public static double length(double x, double y, double z) @ L682

  • 方法名:length
  • 源码定位:L682
  • 返回类型:double
  • 修饰符:public static

参数:

  • x: double
  • y: double
  • z: double

说明:

TODO

public static float lengthSquared(float x, float y, float z) @ L686

  • 方法名:lengthSquared
  • 源码定位:L686
  • 返回类型:float
  • 修饰符:public static

参数:

  • x: float
  • y: float
  • z: float

说明:

TODO

public static int quantize(double value, int quantizeResolution) @ L690

  • 方法名:quantize
  • 源码定位:L690
  • 返回类型:int
  • 修饰符:public static

参数:

  • value: double
  • quantizeResolution: int

说明:

TODO

public static IntStream outFromOrigin(int origin, int lowerBound, int upperBound) @ L694

  • 方法名:outFromOrigin
  • 源码定位:L694
  • 返回类型:IntStream
  • 修饰符:public static

参数:

  • origin: int
  • lowerBound: int
  • upperBound: int

说明:

TODO

public static IntStream outFromOrigin(int origin, int lowerBound, int upperBound, int stepSize) @ L698

  • 方法名:outFromOrigin
  • 源码定位:L698
  • 返回类型:IntStream
  • 修饰符:public static

参数:

  • origin: int
  • lowerBound: int
  • upperBound: int
  • stepSize: int

说明:

TODO

public static Quaternionf rotationAroundAxis(Vector3f axis, Quaternionf rotation, Quaternionf result) @ L724

  • 方法名:rotationAroundAxis
  • 源码定位:L724
  • 返回类型:Quaternionf
  • 修饰符:public static

参数:

  • axis: Vector3f
  • rotation: Quaternionf
  • result: Quaternionf

说明:

TODO

public static int mulAndTruncate(Fraction fraction, int factor) @ L729

  • 方法名:mulAndTruncate
  • 源码定位:L729
  • 返回类型:int
  • 修饰符:public static

参数:

  • fraction: Fraction
  • factor: int

说明:

TODO

代码

public class Mth {
    private static final long UUID_VERSION = 61440L;
    private static final long UUID_VERSION_TYPE_4 = 16384L;
    private static final long UUID_VARIANT = -4611686018427387904L;
    private static final long UUID_VARIANT_2 = Long.MIN_VALUE;
    public static final float PI = (float) Math.PI;
    public static final float HALF_PI = (float) (Math.PI / 2);
    public static final float TWO_PI = (float) (Math.PI * 2);
    public static final float DEG_TO_RAD = (float) (Math.PI / 180.0);
    public static final float RAD_TO_DEG = 180.0F / (float)Math.PI;
    public static final float EPSILON = 1.0E-5F;
    public static final float SQRT_OF_TWO = sqrt(2.0F);
    public static final Vector3f Y_AXIS = new Vector3f(0.0F, 1.0F, 0.0F);
    public static final Vector3f X_AXIS = new Vector3f(1.0F, 0.0F, 0.0F);
    public static final Vector3f Z_AXIS = new Vector3f(0.0F, 0.0F, 1.0F);
    private static final int SIN_QUANTIZATION = 65536;
    private static final int SIN_MASK = 65535;
    private static final int COS_OFFSET = 16384;
    private static final double SIN_SCALE = 10430.378350470453;
    private static final float[] SIN = Util.make(new float[65536], sin -> {
        for (int i = 0; i < sin.length; i++) {
            sin[i] = (float)Math.sin(i / 10430.378350470453);
        }
    });
    private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{
        0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
    };
    private static final double ONE_SIXTH = 0.16666666666666666;
    private static final int FRAC_EXP = 8;
    private static final int LUT_SIZE = 257;
    private static final double FRAC_BIAS = Double.longBitsToDouble(4805340802404319232L);
    private static final double[] ASIN_TAB = new double[257];
    private static final double[] COS_TAB = new double[257];
 
    public static float sin(double i) {
        return SIN[(int)((long)(i * 10430.378350470453) & 65535L)];
    }
 
    public static float cos(double i) {
        return SIN[(int)((long)(i * 10430.378350470453 + 16384.0) & 65535L)];
    }
 
    public static float sqrt(float x) {
        return (float)Math.sqrt(x);
    }
 
    public static int floor(float v) {
        return (int)Math.floor(v);
    }
 
    public static int floor(double v) {
        return (int)Math.floor(v);
    }
 
    public static long lfloor(double v) {
        return (long)Math.floor(v);
    }
 
    public static float abs(float v) {
        return Math.abs(v);
    }
 
    public static int abs(int v) {
        return Math.abs(v);
    }
 
    public static int ceil(float v) {
        return (int)Math.ceil(v);
    }
 
    public static int ceil(double v) {
        return (int)Math.ceil(v);
    }
 
    public static long ceilLong(double v) {
        return (long)Math.ceil(v);
    }
 
    public static int clamp(int value, int min, int max) {
        return Math.min(Math.max(value, min), max);
    }
 
    public static long clamp(long value, long min, long max) {
        return Math.min(Math.max(value, min), max);
    }
 
    public static float clamp(float value, float min, float max) {
        return value < min ? min : Math.min(value, max);
    }
 
    public static double clamp(double value, double min, double max) {
        return value < min ? min : Math.min(value, max);
    }
 
    public static double clampedLerp(double factor, double min, double max) {
        if (factor < 0.0) {
            return min;
        } else {
            return factor > 1.0 ? max : lerp(factor, min, max);
        }
    }
 
    public static float clampedLerp(float factor, float min, float max) {
        if (factor < 0.0F) {
            return min;
        } else {
            return factor > 1.0F ? max : lerp(factor, min, max);
        }
    }
 
    public static int absMax(int a, int b) {
        return Math.max(Math.abs(a), Math.abs(b));
    }
 
    public static float absMax(float a, float b) {
        return Math.max(Math.abs(a), Math.abs(b));
    }
 
    public static double absMax(double a, double b) {
        return Math.max(Math.abs(a), Math.abs(b));
    }
 
    public static int chessboardDistance(int x0, int z0, int x1, int z1) {
        return absMax(x1 - x0, z1 - z0);
    }
 
    public static int floorDiv(int a, int b) {
        return Math.floorDiv(a, b);
    }
 
    public static int nextInt(RandomSource random, int minInclusive, int maxInclusive) {
        return minInclusive >= maxInclusive ? minInclusive : random.nextInt(maxInclusive - minInclusive + 1) + minInclusive;
    }
 
    public static float nextFloat(RandomSource random, float min, float max) {
        return min >= max ? min : random.nextFloat() * (max - min) + min;
    }
 
    public static double nextDouble(RandomSource random, double min, double max) {
        return min >= max ? min : random.nextDouble() * (max - min) + min;
    }
 
    public static boolean equal(float a, float b) {
        return Math.abs(b - a) < 1.0E-5F;
    }
 
    public static boolean equal(double a, double b) {
        return Math.abs(b - a) < 1.0E-5F;
    }
 
    public static int positiveModulo(int input, int mod) {
        return Math.floorMod(input, mod);
    }
 
    public static float positiveModulo(float input, float mod) {
        return (input % mod + mod) % mod;
    }
 
    public static double positiveModulo(double input, double mod) {
        return (input % mod + mod) % mod;
    }
 
    public static boolean isMultipleOf(int dividend, int divisor) {
        return dividend % divisor == 0;
    }
 
    public static byte packDegrees(float angle) {
        return (byte)floor(angle * 256.0F / 360.0F);
    }
 
    public static float unpackDegrees(byte rot) {
        return rot * 360 / 256.0F;
    }
 
    public static int wrapDegrees(int angle) {
        int normalizedAngle = angle % 360;
        if (normalizedAngle >= 180) {
            normalizedAngle -= 360;
        }
 
        if (normalizedAngle < -180) {
            normalizedAngle += 360;
        }
 
        return normalizedAngle;
    }
 
    public static float wrapDegrees(long angle) {
        float normalizedAngle = (float)(angle % 360L);
        if (normalizedAngle >= 180.0F) {
            normalizedAngle -= 360.0F;
        }
 
        if (normalizedAngle < -180.0F) {
            normalizedAngle += 360.0F;
        }
 
        return normalizedAngle;
    }
 
    public static float wrapDegrees(float angle) {
        float normalizedAngle = angle % 360.0F;
        if (normalizedAngle >= 180.0F) {
            normalizedAngle -= 360.0F;
        }
 
        if (normalizedAngle < -180.0F) {
            normalizedAngle += 360.0F;
        }
 
        return normalizedAngle;
    }
 
    public static double wrapDegrees(double angle) {
        double normalizedAngle = angle % 360.0;
        if (normalizedAngle >= 180.0) {
            normalizedAngle -= 360.0;
        }
 
        if (normalizedAngle < -180.0) {
            normalizedAngle += 360.0;
        }
 
        return normalizedAngle;
    }
 
    public static float degreesDifference(float fromAngle, float toAngle) {
        return wrapDegrees(toAngle - fromAngle);
    }
 
    public static float degreesDifferenceAbs(float angleA, float angleB) {
        return abs(degreesDifference(angleA, angleB));
    }
 
    public static float rotateIfNecessary(float baseAngle, float targetAngle, float maxAngleDiff) {
        float deltaAngle = degreesDifference(baseAngle, targetAngle);
        float deltaAngleClamped = clamp(deltaAngle, -maxAngleDiff, maxAngleDiff);
        return targetAngle - deltaAngleClamped;
    }
 
    public static float approach(float current, float target, float increment) {
        increment = abs(increment);
        return current < target ? clamp(current + increment, current, target) : clamp(current - increment, target, current);
    }
 
    public static float approachDegrees(float current, float target, float increment) {
        float difference = degreesDifference(current, target);
        return approach(current, current + difference, increment);
    }
 
    public static int getInt(String input, int def) {
        return NumberUtils.toInt(input, def);
    }
 
    public static int smallestEncompassingPowerOfTwo(int input) {
        int result = input - 1;
        result |= result >> 1;
        result |= result >> 2;
        result |= result >> 4;
        result |= result >> 8;
        result |= result >> 16;
        return result + 1;
    }
 
    public static int smallestSquareSide(int itemCount) {
        if (itemCount < 0) {
            throw new IllegalArgumentException("itemCount must be greater than or equal to zero");
        } else {
            return ceil(Math.sqrt(itemCount));
        }
    }
 
    public static boolean isPowerOfTwo(int input) {
        return input != 0 && (input & input - 1) == 0;
    }
 
    public static int ceillog2(int input) {
        input = isPowerOfTwo(input) ? input : smallestEncompassingPowerOfTwo(input);
        return MULTIPLY_DE_BRUIJN_BIT_POSITION[(int)(input * 125613361L >> 27) & 31];
    }
 
    public static int log2(int input) {
        return ceillog2(input) - (isPowerOfTwo(input) ? 0 : 1);
    }
 
    public static float frac(float num) {
        return num - floor(num);
    }
 
    public static double frac(double num) {
        return num - lfloor(num);
    }
 
    @Deprecated
    public static long getSeed(Vec3i vec) {
        return getSeed(vec.getX(), vec.getY(), vec.getZ());
    }
 
    @Deprecated
    public static long getSeed(int x, int y, int z) {
        long seed = x * 3129871 ^ z * 116129781L ^ y;
        seed = seed * seed * 42317861L + seed * 11L;
        return seed >> 16;
    }
 
    public static UUID createInsecureUUID(RandomSource random) {
        long most = random.nextLong() & -61441L | 16384L;
        long least = random.nextLong() & 4611686018427387903L | Long.MIN_VALUE;
        return new UUID(most, least);
    }
 
    public static double inverseLerp(double value, double min, double max) {
        return (value - min) / (max - min);
    }
 
    public static float inverseLerp(float value, float min, float max) {
        return (value - min) / (max - min);
    }
 
    public static boolean rayIntersectsAABB(Vec3 rayStart, Vec3 rayDir, AABB aabb) {
        double centerX = (aabb.minX + aabb.maxX) * 0.5;
        double boxExtentX = (aabb.maxX - aabb.minX) * 0.5;
        double diffX = rayStart.x - centerX;
        if (Math.abs(diffX) > boxExtentX && diffX * rayDir.x >= 0.0) {
            return false;
        } else {
            double centerY = (aabb.minY + aabb.maxY) * 0.5;
            double boxExtentY = (aabb.maxY - aabb.minY) * 0.5;
            double diffY = rayStart.y - centerY;
            if (Math.abs(diffY) > boxExtentY && diffY * rayDir.y >= 0.0) {
                return false;
            } else {
                double centerZ = (aabb.minZ + aabb.maxZ) * 0.5;
                double boxExtentZ = (aabb.maxZ - aabb.minZ) * 0.5;
                double diffZ = rayStart.z - centerZ;
                if (Math.abs(diffZ) > boxExtentZ && diffZ * rayDir.z >= 0.0) {
                    return false;
                } else {
                    double andrewWooDiffX = Math.abs(rayDir.x);
                    double andrewWooDiffY = Math.abs(rayDir.y);
                    double andrewWooDiffZ = Math.abs(rayDir.z);
                    double f = rayDir.y * diffZ - rayDir.z * diffY;
                    if (Math.abs(f) > boxExtentY * andrewWooDiffZ + boxExtentZ * andrewWooDiffY) {
                        return false;
                    } else {
                        f = rayDir.z * diffX - rayDir.x * diffZ;
                        if (Math.abs(f) > boxExtentX * andrewWooDiffZ + boxExtentZ * andrewWooDiffX) {
                            return false;
                        } else {
                            f = rayDir.x * diffY - rayDir.y * diffX;
                            return Math.abs(f) < boxExtentX * andrewWooDiffY + boxExtentY * andrewWooDiffX;
                        }
                    }
                }
            }
        }
    }
 
    public static double atan2(double y, double x) {
        double d2 = x * x + y * y;
        if (Double.isNaN(d2)) {
            return Double.NaN;
        } else {
            boolean negY = y < 0.0;
            if (negY) {
                y = -y;
            }
 
            boolean negX = x < 0.0;
            if (negX) {
                x = -x;
            }
 
            boolean steep = y > x;
            if (steep) {
                double t = x;
                x = y;
                y = t;
            }
 
            double rinv = fastInvSqrt(d2);
            x *= rinv;
            y *= rinv;
            double yp = FRAC_BIAS + y;
            int index = (int)Double.doubleToRawLongBits(yp);
            double phi = ASIN_TAB[index];
            double cPhi = COS_TAB[index];
            double sPhi = yp - FRAC_BIAS;
            double sd = y * cPhi - x * sPhi;
            double d = (6.0 + sd * sd) * sd * 0.16666666666666666;
            double theta = phi + d;
            if (steep) {
                theta = (Math.PI / 2) - theta;
            }
 
            if (negX) {
                theta = Math.PI - theta;
            }
 
            if (negY) {
                theta = -theta;
            }
 
            return theta;
        }
    }
 
    public static float invSqrt(float x) {
        return org.joml.Math.invsqrt(x);
    }
 
    public static double invSqrt(double x) {
        return org.joml.Math.invsqrt(x);
    }
 
    @Deprecated
    public static double fastInvSqrt(double x) {
        double xhalf = 0.5 * x;
        long i = Double.doubleToRawLongBits(x);
        i = 6910469410427058090L - (i >> 1);
        x = Double.longBitsToDouble(i);
        return x * (1.5 - xhalf * x * x);
    }
 
    public static float fastInvCubeRoot(float x) {
        int i = Float.floatToIntBits(x);
        i = 1419967116 - i / 3;
        float y = Float.intBitsToFloat(i);
        y = 0.6666667F * y + 1.0F / (3.0F * y * y * x);
        return 0.6666667F * y + 1.0F / (3.0F * y * y * x);
    }
 
    public static int hsvToRgb(float hue, float saturation, float value) {
        return hsvToArgb(hue, saturation, value, 0);
    }
 
    public static int hsvToArgb(float hue, float saturation, float value, int alpha) {
        int h = (int)(hue * 6.0F) % 6;
        float f = hue * 6.0F - h;
        float p = value * (1.0F - saturation);
        float q = value * (1.0F - f * saturation);
        float t = value * (1.0F - (1.0F - f) * saturation);
        float red;
        float green;
        float blue;
        switch (h) {
            case 0:
                red = value;
                green = t;
                blue = p;
                break;
            case 1:
                red = q;
                green = value;
                blue = p;
                break;
            case 2:
                red = p;
                green = value;
                blue = t;
                break;
            case 3:
                red = p;
                green = q;
                blue = value;
                break;
            case 4:
                red = t;
                green = p;
                blue = value;
                break;
            case 5:
                red = value;
                green = p;
                blue = q;
                break;
            default:
                throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation + ", " + value);
        }
 
        return ARGB.color(alpha, clamp((int)(red * 255.0F), 0, 255), clamp((int)(green * 255.0F), 0, 255), clamp((int)(blue * 255.0F), 0, 255));
    }
 
    public static int murmurHash3Mixer(int hash) {
        hash ^= hash >>> 16;
        hash *= -2048144789;
        hash ^= hash >>> 13;
        hash *= -1028477387;
        return hash ^ hash >>> 16;
    }
 
    public static int binarySearch(int from, int to, IntPredicate condition) {
        int len = to - from;
 
        while (len > 0) {
            int half = len / 2;
            int middle = from + half;
            if (condition.test(middle)) {
                len = half;
            } else {
                from = middle + 1;
                len -= half + 1;
            }
        }
 
        return from;
    }
 
    public static int lerpInt(float alpha1, int p0, int p1) {
        return p0 + floor(alpha1 * (p1 - p0));
    }
 
    public static int lerpDiscrete(float alpha1, int p0, int p1) {
        int delta = p1 - p0;
        return p0 + floor(alpha1 * (delta - 1)) + (alpha1 > 0.0F ? 1 : 0);
    }
 
    public static float lerp(float alpha1, float p0, float p1) {
        return p0 + alpha1 * (p1 - p0);
    }
 
    public static Vec3 lerp(double alpha, Vec3 p1, Vec3 p2) {
        return new Vec3(lerp(alpha, p1.x, p2.x), lerp(alpha, p1.y, p2.y), lerp(alpha, p1.z, p2.z));
    }
 
    public static double lerp(double alpha1, double p0, double p1) {
        return p0 + alpha1 * (p1 - p0);
    }
 
    public static double lerp2(double alpha1, double alpha2, double x00, double x10, double x01, double x11) {
        return lerp(alpha2, lerp(alpha1, x00, x10), lerp(alpha1, x01, x11));
    }
 
    public static double lerp3(
        double alpha1, double alpha2, double alpha3, double x000, double x100, double x010, double x110, double x001, double x101, double x011, double x111
    ) {
        return lerp(alpha3, lerp2(alpha1, alpha2, x000, x100, x010, x110), lerp2(alpha1, alpha2, x001, x101, x011, x111));
    }
 
    public static float catmullrom(float alpha, float p0, float p1, float p2, float p3) {
        return 0.5F
            * (
                2.0F * p1
                    + (p2 - p0) * alpha
                    + (2.0F * p0 - 5.0F * p1 + 4.0F * p2 - p3) * alpha * alpha
                    + (3.0F * p1 - p0 - 3.0F * p2 + p3) * alpha * alpha * alpha
            );
    }
 
    public static double smoothstep(double x) {
        return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);
    }
 
    public static double smoothstepDerivative(double x) {
        return 30.0 * x * x * (x - 1.0) * (x - 1.0);
    }
 
    public static int sign(double number) {
        if (number == 0.0) {
            return 0;
        } else {
            return number > 0.0 ? 1 : -1;
        }
    }
 
    public static float rotLerp(float a, float from, float to) {
        return from + a * wrapDegrees(to - from);
    }
 
    public static double rotLerp(double a, double from, double to) {
        return from + a * wrapDegrees(to - from);
    }
 
    public static float rotLerpRad(float a, float from, float to) {
        float diff = to - from;
 
        while (diff < (float) -Math.PI) {
            diff += (float) (Math.PI * 2);
        }
 
        while (diff >= (float) Math.PI) {
            diff -= (float) (Math.PI * 2);
        }
 
        return from + a * diff;
    }
 
    public static float triangleWave(float index, float period) {
        return (Math.abs(index % period - period * 0.5F) - period * 0.25F) / (period * 0.25F);
    }
 
    public static float square(float x) {
        return x * x;
    }
 
    public static float cube(float x) {
        return x * x * x;
    }
 
    public static double square(double x) {
        return x * x;
    }
 
    public static int square(int x) {
        return x * x;
    }
 
    public static long square(long x) {
        return x * x;
    }
 
    public static double clampedMap(double value, double fromMin, double fromMax, double toMin, double toMax) {
        return clampedLerp(inverseLerp(value, fromMin, fromMax), toMin, toMax);
    }
 
    public static float clampedMap(float value, float fromMin, float fromMax, float toMin, float toMax) {
        return clampedLerp(inverseLerp(value, fromMin, fromMax), toMin, toMax);
    }
 
    public static double map(double value, double fromMin, double fromMax, double toMin, double toMax) {
        return lerp(inverseLerp(value, fromMin, fromMax), toMin, toMax);
    }
 
    public static float map(float value, float fromMin, float fromMax, float toMin, float toMax) {
        return lerp(inverseLerp(value, fromMin, fromMax), toMin, toMax);
    }
 
    public static double wobble(double coord) {
        return coord + (2.0 * RandomSource.createThreadLocalInstance(floor(coord * 3000.0)).nextDouble() - 1.0) * 1.0E-7 / 2.0;
    }
 
    public static int roundToward(int input, int multiple) {
        return positiveCeilDiv(input, multiple) * multiple;
    }
 
    public static int positiveCeilDiv(int input, int divisor) {
        return -Math.floorDiv(-input, divisor);
    }
 
    public static int randomBetweenInclusive(RandomSource random, int min, int maxInclusive) {
        return random.nextInt(maxInclusive - min + 1) + min;
    }
 
    public static float randomBetween(RandomSource random, float min, float maxExclusive) {
        return random.nextFloat() * (maxExclusive - min) + min;
    }
 
    public static float normal(RandomSource random, float mean, float deviation) {
        return mean + (float)random.nextGaussian() * deviation;
    }
 
    public static double lengthSquared(double x, double y) {
        return x * x + y * y;
    }
 
    public static double length(double x, double y) {
        return Math.sqrt(lengthSquared(x, y));
    }
 
    public static float length(float x, float y) {
        return (float)Math.sqrt(lengthSquared(x, y));
    }
 
    public static double lengthSquared(double x, double y, double z) {
        return x * x + y * y + z * z;
    }
 
    public static double length(double x, double y, double z) {
        return Math.sqrt(lengthSquared(x, y, z));
    }
 
    public static float lengthSquared(float x, float y, float z) {
        return x * x + y * y + z * z;
    }
 
    public static int quantize(double value, int quantizeResolution) {
        return floor(value / quantizeResolution) * quantizeResolution;
    }
 
    public static IntStream outFromOrigin(int origin, int lowerBound, int upperBound) {
        return outFromOrigin(origin, lowerBound, upperBound, 1);
    }
 
    public static IntStream outFromOrigin(int origin, int lowerBound, int upperBound, int stepSize) {
        if (lowerBound > upperBound) {
            throw new IllegalArgumentException(String.format(Locale.ROOT, "upperBound %d expected to be > lowerBound %d", upperBound, lowerBound));
        } else if (stepSize < 1) {
            throw new IllegalArgumentException(String.format(Locale.ROOT, "step size expected to be >= 1, was %d", stepSize));
        } else {
            int clampedOrigin = clamp(origin, lowerBound, upperBound);
            return IntStream.iterate(clampedOrigin, cursor -> {
                int currentDistance = Math.abs(clampedOrigin - cursor);
                return clampedOrigin - currentDistance >= lowerBound || clampedOrigin + currentDistance <= upperBound;
            }, cursor -> {
                boolean previousWasNegative = cursor <= clampedOrigin;
                int currentDistance = Math.abs(clampedOrigin - cursor);
                boolean canMovePositive = clampedOrigin + currentDistance + stepSize <= upperBound;
                if (!previousWasNegative || !canMovePositive) {
                    int attemptedStep = clampedOrigin - currentDistance - (previousWasNegative ? stepSize : 0);
                    if (attemptedStep >= lowerBound) {
                        return attemptedStep;
                    }
                }
 
                return clampedOrigin + currentDistance + stepSize;
            });
        }
    }
 
    public static Quaternionf rotationAroundAxis(Vector3f axis, Quaternionf rotation, Quaternionf result) {
        float projectedLength = axis.dot(rotation.x, rotation.y, rotation.z);
        return result.set(axis.x * projectedLength, axis.y * projectedLength, axis.z * projectedLength, rotation.w).normalize();
    }
 
    public static int mulAndTruncate(Fraction fraction, int factor) {
        return fraction.getNumerator() * factor / fraction.getDenominator();
    }
 
    static {
        for (int ind = 0; ind < 257; ind++) {
            double v = ind / 256.0;
            double asinv = Math.asin(v);
            COS_TAB[ind] = Math.cos(asinv);
            ASIN_TAB[ind] = asinv;
        }
    }
}

引用的其他类

  • Vec3i

    • 引用位置: 参数
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.color()
  • RandomSource

    • 引用位置: 参数/方法调用
    • 关联成员: RandomSource.createThreadLocalInstance()
  • Util

    • 引用位置: 方法调用
    • 关联成员: Util.make()
  • LevelBasedValue

    • 引用位置: 参数
  • AABB

    • 引用位置: 参数
  • Vec3

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: Vec3()