@lijuhong1981/jsmath 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./src/acosClamped.js";
1
2
  export * from "./src/clamp.js";
2
3
  export * from "./src/clampLatitude.js";
3
4
  export * from "./src/clampLongitude.js";
@@ -24,3 +25,4 @@ export * from "./src/randomNumber.js";
24
25
  export * from "./src/scalarInRange.js";
25
26
  export * from "./src/toFixed.js";
26
27
  export * from "./src/windowPositionToNDC.js";
28
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lijuhong1981/jsmath",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "> TODO: description",
5
5
  "author": "lijuhong1981 <lijuhong@hotmail.com>",
6
6
  "homepage": "https://github.com/lijuhong1981/jslibs#readme",
@@ -0,0 +1,13 @@
1
+ import clamp from "./clamp";
2
+
3
+ /**
4
+ * 计算一个数值的反余弦值,并将输入值约束在-1到1之间
5
+ * @param {number} value 需要计算反余弦值的数值
6
+ * @return {number} 反余弦值
7
+ */
8
+ function acosClamped(value) {
9
+ return Math.acos(clamp(value, -1.0, 1.0));
10
+ };
11
+
12
+ export default acosClamped;
13
+ export { acosClamped };
package/src/clamp.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * 将一个数值约束在两个数值之间
3
3
  * @param {Number} value 需要约束的数值
4
- * @param {Number} rangeMinimum 较小数
5
- * @param {Number} rangeMaximum 较大数
4
+ * @param {Number} min 较小数
5
+ * @param {Number} max 较大数
6
6
  * @returns {Number} 约束后的数值
7
7
  */
8
- function clamp(value, rangeMinimum, rangeMaximum) {
9
- return value < rangeMinimum ? rangeMinimum : value > rangeMaximum ? rangeMaximum : value;
8
+ function clamp(value, min, max) {
9
+ return value < min ? min : value > max ? max : value;
10
10
  };
11
11
 
12
12
  export default clamp;