@@ -69,6 +69,58 @@ export function approx (a: number, b: number, maxDiff?: number): boolean {
6969 return mathAbs ( a - b ) <= maxDiff ;
7070}
7171
72+ /**
73+ * @en Tests whether or not the first argument is approximately greater than or equal to the second
74+ * @zh 测试第一个参数是否近似大于或等于第二个参数
75+ * @param a The first number to test
76+ * @param b The second number to test
77+ * @param maxDiff Maximum difference (default: EPSILON)
78+ * @return True if a is approximately greater than or equal to b, false otherwise
79+ */
80+ export function approxGE ( a : number , b : number , maxDiff ?: number ) : boolean {
81+ maxDiff = maxDiff || EPSILON ;
82+ return a >= b - maxDiff ;
83+ }
84+
85+ /**
86+ * @en Tests whether or not the first argument is approximately less than or equal to the second
87+ * @zh 测试第一个参数是否近似小于或等于第二个参数
88+ * @param a The first number to test
89+ * @param b The second number to test
90+ * @param maxDiff Maximum difference (default: EPSILON)
91+ * @return True if a is approximately less than or equal to b, false otherwise
92+ */
93+ export function approxLE ( a : number , b : number , maxDiff ?: number ) : boolean {
94+ maxDiff = maxDiff || EPSILON ;
95+ return a <= b + maxDiff ;
96+ }
97+
98+ /**
99+ * @en Tests whether or not the first argument is approximately greater than the second
100+ * @zh 测试第一个参数是否近似大于第二个参数
101+ * @param a The first number to test
102+ * @param b The second number to test
103+ * @param maxDiff Maximum difference (default: EPSILON)
104+ * @return True if a is approximately greater than b, false otherwise
105+ */
106+ export function approxGT ( a : number , b : number , maxDiff ?: number ) : boolean {
107+ maxDiff = maxDiff || EPSILON ;
108+ return a > b + maxDiff ;
109+ }
110+
111+ /**
112+ * @en Tests whether or not the first argument is approximately less than the second
113+ * @zh 测试第一个参数是否近似小于第二个参数
114+ * @param a The first number to test
115+ * @param b The second number to test
116+ * @param maxDiff Maximum difference (default: EPSILON)
117+ * @return True if a is approximately less than b, false otherwise
118+ */
119+ export function approxLT ( a : number , b : number , maxDiff ?: number ) : boolean {
120+ maxDiff = maxDiff || EPSILON ;
121+ return a < b - maxDiff ;
122+ }
123+
72124/**
73125 * @en Clamps a value between a minimum float and maximum float value.<br/>
74126 * @zh 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。
0 commit comments