@lijuhong1981/jsmath 1.3.6 → 1.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lijuhong1981/jsmath",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Math utilities: interpolation, clamp, coordinates and random.",
5
5
  "author": "lijuhong1981 <lijuhong@hotmail.com>",
6
6
  "homepage": "https://github.com/lijuhong1981/jslibs#readme",
@@ -18,5 +18,5 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/lijuhong1981/jslibs/issues"
20
20
  },
21
- "gitHead": "e968d936633601ce59f5c9aa99c36143b66a1de2"
21
+ "gitHead": "5d4bd57b654be98c46364160070d5dd11600afa6"
22
22
  }
package/src/Constant.js CHANGED
@@ -10,7 +10,7 @@ const ONE_OVER_TWO_PI = 1.0 / (2.0 * PI);
10
10
  const RADIANS_PER_DEGREE = PI / 180.0;
11
11
  const DEGREES_PER_RADIAN = 180.0 / PI;
12
12
  /**
13
- * The number of radians in an arc second.
13
+ * 一弧秒所对应的弧度数。
14
14
  *
15
15
  * @type {number}
16
16
  * @constant
@@ -1,4 +1,4 @@
1
- import clamp from "./clamp";
1
+ import clamp from "./clamp.js";
2
2
 
3
3
  /**
4
4
  * 计算一个数值的反余弦值,并将输入值约束在-1到1之间
@@ -8,6 +8,8 @@
8
8
  */
9
9
  function convertToRange(value, rangeMinimum, rangeMaximum) {
10
10
  const length = rangeMaximum - rangeMinimum;
11
+ if (length === 0)
12
+ return rangeMinimum;
11
13
  if (value < rangeMinimum) {
12
14
  value += length;
13
15
  while (value < rangeMinimum)
@@ -4,12 +4,7 @@
4
4
  * @returns {Number} 提取的小数
5
5
  */
6
6
  function extractFraction(value) {
7
- value = value.toString();
8
- const arr = value.split('.');
9
- if (arr.length === 2)
10
- return parseFloat('0.' + arr[1]);
11
- else
12
- return 0.0;
7
+ return value - Math.trunc(value);
13
8
  };
14
9
 
15
10
  export default extractFraction;
@@ -3,7 +3,7 @@ import randomNumber from "./randomNumber.js";
3
3
  /**
4
4
  * 产生一个随机整数,可指定随机范围
5
5
  * @param {Number} rangeMinimum 最小整数,默认0
6
- * @param {Number} rangeMaximum 最大整数,默认Number.MAX_SAFE_INTEGER
6
+ * @param {Number} rangeMaximum 最大整数,默认Number.MAX_SAFE_INTEGER - 1
7
7
  * @returns {Integer} 生成的随机整数
8
8
  */
9
9
  function randomInteger(rangeMinimum = 0, rangeMaximum = Number.MAX_SAFE_INTEGER - 1) {