diginext-utils 1.1.6 → 1.1.8
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/dist/math/index.js +23 -2
- package/package.json +1 -1
package/dist/math/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.randRound = exports.randInt = exports.randHalt = exports.randFloat = exports.rand = exports.radToDeg = exports.degToRad = void 0;
|
|
6
|
+
exports.randRound = exports.randInt = exports.randHalt = exports.randFloat = exports.rand = exports.radToDeg = exports.degToRad = exports.angleBetweenPoints = void 0;
|
|
7
7
|
const DEG2RAD = Math.PI / 180;
|
|
8
8
|
const RAD2DEG = 180 / Math.PI;
|
|
9
9
|
/**
|
|
@@ -97,6 +97,27 @@ exports.degToRad = degToRad;
|
|
|
97
97
|
|
|
98
98
|
const radToDeg = radians => {
|
|
99
99
|
return radians * RAD2DEG;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param {Number} cx
|
|
104
|
+
* @param {Number} cy
|
|
105
|
+
* @param {Number} ex
|
|
106
|
+
* @param {Number} ey
|
|
107
|
+
* @returns {Number}
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
exports.radToDeg = radToDeg;
|
|
112
|
+
|
|
113
|
+
const angleBetweenPoints = (cx, cy, ex, ey) => {
|
|
114
|
+
var dy = ey - cy;
|
|
115
|
+
var dx = ex - cx;
|
|
116
|
+
var theta = Math.atan2(dy, dx); // range (-PI, PI]
|
|
117
|
+
|
|
118
|
+
theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
|
|
119
|
+
|
|
120
|
+
return theta;
|
|
100
121
|
}; // const MathExtra = {
|
|
101
122
|
// isRotateLeft(a, b, c) {
|
|
102
123
|
// return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > 0;
|
|
@@ -206,4 +227,4 @@ const radToDeg = radians => {
|
|
|
206
227
|
// export default MathExtra;
|
|
207
228
|
|
|
208
229
|
|
|
209
|
-
exports.
|
|
230
|
+
exports.angleBetweenPoints = angleBetweenPoints;
|