MathHelper

public class MathHelper

常见数学运算的静态函数。

公共构造函数

公共方法

静态布尔值
almostEqualRelativeAndAbs(浮点值 a、浮点数 b)
如果两个浮点数在公差范围内相等,则返回 true。
静态浮点数
clamp(浮点值、浮点数下限、浮点数最大值)
限制一个介于最小值和最大值之间的值。
静态浮点数
lerp(浮点数 a、浮点数 b、浮点数 t)
按比率线性插值 a 和 b。

继承的方法

公共构造函数

public MathHelper ()

公共方法

public static boolean almostEqualRelativeAndAbs (float a, float b)

如果两个浮点数在公差范围内相等,则返回 true。用于比较浮点数,同时兼顾浮点精度的限制。

参数
a
b

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

限制一个介于最小值和最大值之间的值。

参数
分钟
最大值

public static float lerp (float a, float b, float t)

按比率线性插值 a 和 b。

参数
a 起始值
b 结束值
t 两个浮点数之比
返回
  • 两个浮点数之间的插值