@pie-lib/graphing-utils 1.2.0-beta.2 → 1.2.0-beta.4
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/CHANGELOG.md +40 -0
- package/lib/index.js +343 -0
- package/lib/index.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.2.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.4) (2025-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/graphing-utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.2.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.3) (2025-07-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/graphing-utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.2.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.3) (2025-07-20)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-lib/graphing-utils
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [1.2.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.2) (2025-07-20)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/graphing-utils
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [1.2.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.1) (2025-07-20)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-lib/graphing-utils
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
6
46
|
# [1.2.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing-utils@1.1.33...@pie-lib/graphing-utils@1.2.0-beta.2) (2025-07-20)
|
|
7
47
|
|
|
8
48
|
**Note:** Version bump only for package @pie-lib/graphing-utils
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.xPoints = exports.sinY = exports.pointsToAForAbsolute = exports.pointsToABForExponential = exports.pointsToABC = exports.parabolaFromTwoPoints = exports.parabolaFromThreePoints = exports.parabola = exports.getAmplitudeAndFreq = exports.exponentialFromTwoPoints = exports.exponential = exports["default"] = exports.buildDataPoints = exports.absoluteFromTwoPoints = exports.absolute = exports.FREQ_DIVIDER = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
15
|
+
|
|
16
|
+
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
17
|
+
|
|
18
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
24
|
+
var log = (0, _debug["default"])('pie-lib:graphing:tools:utils');
|
|
25
|
+
var FREQ_DIVIDER = 16;
|
|
26
|
+
exports.FREQ_DIVIDER = FREQ_DIVIDER;
|
|
27
|
+
|
|
28
|
+
var getAmplitudeAndFreq = function getAmplitudeAndFreq(root, edge) {
|
|
29
|
+
if (!edge) {
|
|
30
|
+
return {
|
|
31
|
+
freq: 0,
|
|
32
|
+
amplitude: 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (root.x == edge.x) {
|
|
37
|
+
return {
|
|
38
|
+
freq: 0,
|
|
39
|
+
amplitude: 0
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var r = new _pointGeometry["default"](root.x, root.y);
|
|
44
|
+
var e = new _pointGeometry["default"](edge.x, edge.y);
|
|
45
|
+
var d = e.sub(r); // edge point describes 1/4 of the freq
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
freq: d.x * 4,
|
|
49
|
+
amplitude: d.y
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* build the x points with root as the anchor.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
exports.getAmplitudeAndFreq = getAmplitudeAndFreq;
|
|
58
|
+
|
|
59
|
+
var xPoints = function xPoints(root, freq, min, max) {
|
|
60
|
+
freq = Math.abs(freq);
|
|
61
|
+
log('[xPoints] root:', root, 'freq:', freq, ' min:', min, ' max:', max);
|
|
62
|
+
|
|
63
|
+
var leftpoints = _lodash["default"].rangeRight(root, min - freq, freq * -1);
|
|
64
|
+
|
|
65
|
+
var rightpoints = _lodash["default"].range(root + freq, max + freq, freq);
|
|
66
|
+
|
|
67
|
+
return _lodash["default"].concat(leftpoints, rightpoints);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Calculate y for x value using amp, freq and shift
|
|
71
|
+
* https://www.desmos.com/calculator/f1psfoiiv6
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
exports.xPoints = xPoints;
|
|
76
|
+
|
|
77
|
+
var sinY = function sinY(amplitude, freq, shift) {
|
|
78
|
+
return function (x) {
|
|
79
|
+
shift = _objectSpread({
|
|
80
|
+
phase: 0,
|
|
81
|
+
vertical: 0
|
|
82
|
+
}, shift);
|
|
83
|
+
var TWO_PI = Math.PI * 2;
|
|
84
|
+
var num = TWO_PI * (x - shift.phase);
|
|
85
|
+
var frac = num / freq;
|
|
86
|
+
var sin = Math.sin(frac);
|
|
87
|
+
var sinFloat = parseFloat(sin).toFixed(10);
|
|
88
|
+
return amplitude * sinFloat + shift.vertical;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* You need three points for the quadratic eq, so we mirror the edge point
|
|
93
|
+
* https://www.desmos.com/calculator/xhz1xqgpca
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
exports.sinY = sinY;
|
|
98
|
+
|
|
99
|
+
var parabolaFromTwoPoints = function parabolaFromTwoPoints(root, edge) {
|
|
100
|
+
edge = edge || _objectSpread({}, root);
|
|
101
|
+
var mirrorEdge = {
|
|
102
|
+
x: root.x - (edge.x - root.x),
|
|
103
|
+
y: edge.y
|
|
104
|
+
};
|
|
105
|
+
return parabolaFromThreePoints(root, edge, mirrorEdge);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.parabolaFromTwoPoints = parabolaFromTwoPoints;
|
|
109
|
+
|
|
110
|
+
var parabolaFromThreePoints = function parabolaFromThreePoints(one, two, three) {
|
|
111
|
+
log(one, two, three);
|
|
112
|
+
|
|
113
|
+
var _pointsToABC = pointsToABC(one, two, three),
|
|
114
|
+
a = _pointsToABC.a,
|
|
115
|
+
b = _pointsToABC.b,
|
|
116
|
+
c = _pointsToABC.c;
|
|
117
|
+
|
|
118
|
+
log(a, b, c);
|
|
119
|
+
return parabola(a, b, c);
|
|
120
|
+
};
|
|
121
|
+
/** derive a,b,c from the 3 points */
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
exports.parabolaFromThreePoints = parabolaFromThreePoints;
|
|
125
|
+
|
|
126
|
+
var pointsToABC = function pointsToABC(one, two, three) {
|
|
127
|
+
var a1 = Math.pow(one.x, 2) * -1 + Math.pow(two.x, 2);
|
|
128
|
+
var b1 = one.x * -1 + two.x;
|
|
129
|
+
var d1 = one.y * -1 + two.y;
|
|
130
|
+
var a2 = Math.pow(two.x, 2) * -1 + Math.pow(three.x, 2);
|
|
131
|
+
var b2 = two.x * -1 + three.x;
|
|
132
|
+
var d2 = two.y * -1 + three.y;
|
|
133
|
+
var bMult = b2 / b1 * -1;
|
|
134
|
+
var a3 = bMult * a1 + a2;
|
|
135
|
+
var d3 = bMult * d1 + d2;
|
|
136
|
+
var a = d3 / a3;
|
|
137
|
+
var b = (d1 - a1 * a) / b1;
|
|
138
|
+
var c = one.y - a * Math.pow(one.x, 2) - b * one.x;
|
|
139
|
+
return {
|
|
140
|
+
a: a,
|
|
141
|
+
b: b,
|
|
142
|
+
c: c
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* y=ax^2+bx+c
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
exports.pointsToABC = pointsToABC;
|
|
151
|
+
|
|
152
|
+
var parabola = function parabola(a, b, c) {
|
|
153
|
+
return function (x) {
|
|
154
|
+
return a * Math.pow(x, 2) + b * x + c;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Absolute value from two points Root (Vertex) the point where the two rays intersect and edge One point on a ray.
|
|
159
|
+
* @param root 1st point selected on graph
|
|
160
|
+
* @param edge 2nd point selected on graph
|
|
161
|
+
* https://www.desmos.com/calculator/rarxiatpip
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
exports.parabola = parabola;
|
|
166
|
+
|
|
167
|
+
var absoluteFromTwoPoints = function absoluteFromTwoPoints(root, edge) {
|
|
168
|
+
edge = edge || _objectSpread({}, root);
|
|
169
|
+
var a = pointsToAForAbsolute(root, edge);
|
|
170
|
+
return absolute(a, root.x, root.y);
|
|
171
|
+
};
|
|
172
|
+
/*
|
|
173
|
+
* Finds value of a in y=a*abs(x-h)+k function
|
|
174
|
+
* @param one 1st point
|
|
175
|
+
* @param two 2nd point
|
|
176
|
+
* */
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
exports.absoluteFromTwoPoints = absoluteFromTwoPoints;
|
|
180
|
+
|
|
181
|
+
var pointsToAForAbsolute = function pointsToAForAbsolute(one, two) {
|
|
182
|
+
var y1 = two.y - one.y;
|
|
183
|
+
var x1 = two.x - one.x;
|
|
184
|
+
var a = y1 / x1;
|
|
185
|
+
|
|
186
|
+
if (two.x < one.x) {
|
|
187
|
+
a = a * -1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return a;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* y=a*abs(x-h)+k
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
exports.pointsToAForAbsolute = pointsToAForAbsolute;
|
|
198
|
+
|
|
199
|
+
var absolute = function absolute(a, h, k) {
|
|
200
|
+
return function (x) {
|
|
201
|
+
return a * Math.abs(x - h) + k;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Exponential from two points on exponential graph.
|
|
206
|
+
* @param root 1st point selected on graph
|
|
207
|
+
* @param edge 2nd point selected on graph
|
|
208
|
+
* https://www.desmos.com/calculator/3fisjexbvp
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
exports.absolute = absolute;
|
|
213
|
+
|
|
214
|
+
var exponentialFromTwoPoints = function exponentialFromTwoPoints(root, edge) {
|
|
215
|
+
edge = edge || _objectSpread({}, root);
|
|
216
|
+
|
|
217
|
+
var _pointsToABForExponen = pointsToABForExponential(root, edge),
|
|
218
|
+
a = _pointsToABForExponen.a,
|
|
219
|
+
b = _pointsToABForExponen.b;
|
|
220
|
+
|
|
221
|
+
return exponential(a, b);
|
|
222
|
+
};
|
|
223
|
+
/*
|
|
224
|
+
* Finds value of a and b in y=a*(b)^x function
|
|
225
|
+
* @param one 1st point
|
|
226
|
+
* @param two 2nd point
|
|
227
|
+
* */
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
exports.exponentialFromTwoPoints = exponentialFromTwoPoints;
|
|
231
|
+
|
|
232
|
+
var pointsToABForExponential = function pointsToABForExponential(one, two) {
|
|
233
|
+
var p = one.y / two.y;
|
|
234
|
+
var r = 1 / (one.x - two.x);
|
|
235
|
+
var b = Math.pow(p, r);
|
|
236
|
+
var a = one.y / Math.pow(b, one.x);
|
|
237
|
+
return {
|
|
238
|
+
a: a,
|
|
239
|
+
b: b
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* y=a*(b)^x
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
exports.pointsToABForExponential = pointsToABForExponential;
|
|
248
|
+
|
|
249
|
+
var exponential = function exponential(a, b) {
|
|
250
|
+
return function (x) {
|
|
251
|
+
return a * Math.pow(b, x);
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Generate a set of data points, add spacing before min and after max if there is space between minx + min and maxX and max
|
|
256
|
+
* @param {*} domain
|
|
257
|
+
* @param {*} range
|
|
258
|
+
* @param {*} root
|
|
259
|
+
* @param {*} edge
|
|
260
|
+
* @param {*} yFn
|
|
261
|
+
* @param {*} excludeOutsidePoints
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
exports.exponential = exponential;
|
|
266
|
+
|
|
267
|
+
var buildDataPoints = function buildDataPoints(domain, range, root, edge, yFn) {
|
|
268
|
+
var excludeOutsidePoints = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
269
|
+
log('[buildDataPoints] domain:', domain, 'range:', range, 'root:', root, 'edge:', edge);
|
|
270
|
+
domain = _objectSpread({
|
|
271
|
+
min: 0,
|
|
272
|
+
max: 0,
|
|
273
|
+
step: 1
|
|
274
|
+
}, domain);
|
|
275
|
+
range = _objectSpread({
|
|
276
|
+
min: 0,
|
|
277
|
+
max: 0,
|
|
278
|
+
step: 1
|
|
279
|
+
}, range);
|
|
280
|
+
edge = edge ? edge : _objectSpread({}, root);
|
|
281
|
+
var minX = Math.min(root.x, edge.x);
|
|
282
|
+
var xPts = xPoints(minX, domain.step, domain.min - domain.step, domain.max + domain.step);
|
|
283
|
+
log('[buildDataPoints]:xPts:', xPts);
|
|
284
|
+
var startIndex = -1;
|
|
285
|
+
var endIndex = -1; // generate points based on the yFn
|
|
286
|
+
|
|
287
|
+
var points = xPts.map(function (v) {
|
|
288
|
+
return new _pointGeometry["default"](v, yFn(v));
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
if (!excludeOutsidePoints) {
|
|
292
|
+
return points;
|
|
293
|
+
} // exclude the points with y outside range min and max
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
var filteredPoints = points.reduce(function (acc, val, index) {
|
|
297
|
+
if (val.y >= range.min - range.step && val.y <= range.max + range.step) {
|
|
298
|
+
if (startIndex === -1) {
|
|
299
|
+
startIndex = index;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (endIndex < index) {
|
|
303
|
+
endIndex = index;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return [].concat((0, _toConsumableArray2["default"])(acc), [val]);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return acc;
|
|
310
|
+
}, []); // add the first value outside range min and max smaller than range.min if exists
|
|
311
|
+
|
|
312
|
+
if (startIndex - 1 >= 0) {
|
|
313
|
+
filteredPoints.unshift(points[startIndex - 1]);
|
|
314
|
+
} // add the first value outside range min and max greater than range.min if exists
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
if (endIndex + 1 <= points.length - 1) {
|
|
318
|
+
filteredPoints.push(points[endIndex + 1]);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return points;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
exports.buildDataPoints = buildDataPoints;
|
|
325
|
+
var _default = {
|
|
326
|
+
FREQ_DIVIDER: FREQ_DIVIDER,
|
|
327
|
+
getAmplitudeAndFreq: getAmplitudeAndFreq,
|
|
328
|
+
xPoints: xPoints,
|
|
329
|
+
sinY: sinY,
|
|
330
|
+
parabolaFromTwoPoints: parabolaFromTwoPoints,
|
|
331
|
+
parabolaFromThreePoints: parabolaFromThreePoints,
|
|
332
|
+
pointsToABC: pointsToABC,
|
|
333
|
+
parabola: parabola,
|
|
334
|
+
absoluteFromTwoPoints: absoluteFromTwoPoints,
|
|
335
|
+
pointsToAForAbsolute: pointsToAForAbsolute,
|
|
336
|
+
absolute: absolute,
|
|
337
|
+
exponentialFromTwoPoints: exponentialFromTwoPoints,
|
|
338
|
+
pointsToABForExponential: pointsToABForExponential,
|
|
339
|
+
exponential: exponential,
|
|
340
|
+
buildDataPoints: buildDataPoints
|
|
341
|
+
};
|
|
342
|
+
exports["default"] = _default;
|
|
343
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","FREQ_DIVIDER","getAmplitudeAndFreq","root","edge","freq","amplitude","x","r","Point","y","e","d","sub","xPoints","min","max","Math","abs","leftpoints","_","rangeRight","rightpoints","range","concat","sinY","shift","phase","vertical","TWO_PI","PI","num","frac","sin","sinFloat","parseFloat","toFixed","parabolaFromTwoPoints","mirrorEdge","parabolaFromThreePoints","one","two","three","pointsToABC","a","b","c","parabola","a1","pow","b1","d1","a2","b2","d2","bMult","a3","d3","absoluteFromTwoPoints","pointsToAForAbsolute","absolute","y1","x1","h","k","exponentialFromTwoPoints","pointsToABForExponential","exponential","p","buildDataPoints","domain","yFn","excludeOutsidePoints","step","minX","xPts","startIndex","endIndex","points","map","v","filteredPoints","reduce","acc","val","index","unshift","length","push"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,8BAAN,CAAZ;AAEO,IAAMC,YAAY,GAAG,EAArB;;;AAEA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,IAAD,EAAOC,IAAP,EAAgB;AACjD,MAAI,CAACA,IAAL,EAAW;AACT,WAAO;AAAEC,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,SAAS,EAAE;AAAtB,KAAP;AACD;;AAED,MAAIH,IAAI,CAACI,CAAL,IAAUH,IAAI,CAACG,CAAnB,EAAsB;AACpB,WAAO;AAAEF,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,SAAS,EAAE;AAAtB,KAAP;AACD;;AAED,MAAME,CAAC,GAAG,IAAIC,yBAAJ,CAAUN,IAAI,CAACI,CAAf,EAAkBJ,IAAI,CAACO,CAAvB,CAAV;AACA,MAAMC,CAAC,GAAG,IAAIF,yBAAJ,CAAUL,IAAI,CAACG,CAAf,EAAkBH,IAAI,CAACM,C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CAAZ,CAA1B;AACD;;AAED,SAAOC,MAAP;AACD,CAlDM;;;eAoDQ;AACb7E,EAAAA,YAAY,EAAZA,YADa;AAEbC,EAAAA,mBAAmB,EAAnBA,mBAFa;AAGbY,EAAAA,OAAO,EAAPA,OAHa;AAIbW,EAAAA,IAAI,EAAJA,IAJa;AAKbY,EAAAA,qBAAqB,EAArBA,qBALa;AAMbE,EAAAA,uBAAuB,EAAvBA,uBANa;AAObI,EAAAA,WAAW,EAAXA,WAPa;AAQbI,EAAAA,QAAQ,EAARA,QARa;AASbW,EAAAA,qBAAqB,EAArBA,qBATa;AAUbC,EAAAA,oBAAoB,EAApBA,oBAVa;AAWbC,EAAAA,QAAQ,EAARA,QAXa;AAYbK,EAAAA,wBAAwB,EAAxBA,wBAZa;AAabC,EAAAA,wBAAwB,EAAxBA,wBAba;AAcbC,EAAAA,WAAW,EAAXA,WAda;AAebE,EAAAA,eAAe,EAAfA;AAfa,C","sourcesContent":["import debug from 'debug';\nimport Point from '@mapbox/point-geometry';\nimport _ from 'lodash';\nconst log = debug('pie-lib:graphing:tools:utils');\n\nexport const FREQ_DIVIDER = 16;\n\nexport const getAmplitudeAndFreq = (root, edge) => {\n if (!edge) {\n return { freq: 0, amplitude: 0 };\n }\n\n if (root.x == edge.x) {\n return { freq: 0, amplitude: 0 };\n }\n\n const r = new Point(root.x, root.y);\n const e = new Point(edge.x, edge.y);\n const d = e.sub(r);\n // edge point describes 1/4 of the freq\n return { freq: d.x * 4, amplitude: d.y };\n};\n\n/**\n * build the x points with root as the anchor.\n */\nexport const xPoints = (root, freq, min, max) => {\n freq = Math.abs(freq);\n log('[xPoints] root:', root, 'freq:', freq, ' min:', min, ' max:', max);\n const leftpoints = _.rangeRight(root, min - freq, freq * -1);\n const rightpoints = _.range(root + freq, max + freq, freq);\n\n return _.concat(leftpoints, rightpoints);\n};\n\n/**\n * Calculate y for x value using amp, freq and shift\n * https://www.desmos.com/calculator/f1psfoiiv6\n */\nexport const sinY = (amplitude, freq, shift) => (x) => {\n shift = { phase: 0, vertical: 0, ...shift };\n const TWO_PI = Math.PI * 2;\n const num = TWO_PI * (x - shift.phase);\n const frac = num / freq;\n const sin = Math.sin(frac);\n const sinFloat = parseFloat(sin).toFixed(10);\n return amplitude * sinFloat + shift.vertical;\n};\n\n/**\n * You need three points for the quadratic eq, so we mirror the edge point\n * https://www.desmos.com/calculator/xhz1xqgpca\n */\nexport const parabolaFromTwoPoints = (root, edge) => {\n edge = edge || { ...root };\n const mirrorEdge = { x: root.x - (edge.x - root.x), y: edge.y };\n return parabolaFromThreePoints(root, edge, mirrorEdge);\n};\n\nexport const parabolaFromThreePoints = (one, two, three) => {\n log(one, two, three);\n const { a, b, c } = pointsToABC(one, two, three);\n log(a, b, c);\n return parabola(a, b, c);\n};\n/** derive a,b,c from the 3 points */\nexport const pointsToABC = (one, two, three) => {\n const a1 = Math.pow(one.x, 2) * -1 + Math.pow(two.x, 2);\n const b1 = one.x * -1 + two.x;\n const d1 = one.y * -1 + two.y;\n const a2 = Math.pow(two.x, 2) * -1 + Math.pow(three.x, 2);\n const b2 = two.x * -1 + three.x;\n const d2 = two.y * -1 + three.y;\n const bMult = (b2 / b1) * -1;\n const a3 = bMult * a1 + a2;\n const d3 = bMult * d1 + d2;\n const a = d3 / a3;\n const b = (d1 - a1 * a) / b1;\n const c = one.y - a * Math.pow(one.x, 2) - b * one.x;\n return { a, b, c };\n};\n\n/**\n * y=ax^2+bx+c\n */\nexport const parabola = (a, b, c) => (x) => a * Math.pow(x, 2) + b * x + c;\n\n/**\n * Absolute value from two points Root (Vertex) the point where the two rays intersect and edge One point on a ray.\n * @param root 1st point selected on graph\n * @param edge 2nd point selected on graph\n * https://www.desmos.com/calculator/rarxiatpip\n */\nexport const absoluteFromTwoPoints = (root, edge) => {\n edge = edge || { ...root };\n const a = pointsToAForAbsolute(root, edge);\n return absolute(a, root.x, root.y);\n};\n\n/*\n * Finds value of a in y=a*abs(x-h)+k function\n * @param one 1st point\n * @param two 2nd point\n * */\nexport const pointsToAForAbsolute = (one, two) => {\n const y1 = two.y - one.y;\n const x1 = two.x - one.x;\n let a = y1 / x1;\n if (two.x < one.x) {\n a = a * -1;\n }\n return a;\n};\n\n/**\n * y=a*abs(x-h)+k\n */\nexport const absolute = (a, h, k) => (x) => a * Math.abs(x - h) + k;\n\n/**\n * Exponential from two points on exponential graph.\n * @param root 1st point selected on graph\n * @param edge 2nd point selected on graph\n * https://www.desmos.com/calculator/3fisjexbvp\n */\nexport const exponentialFromTwoPoints = (root, edge) => {\n edge = edge || { ...root };\n const { a, b } = pointsToABForExponential(root, edge);\n return exponential(a, b);\n};\n\n/*\n * Finds value of a and b in y=a*(b)^x function\n * @param one 1st point\n * @param two 2nd point\n * */\nexport const pointsToABForExponential = (one, two) => {\n const p = one.y / two.y;\n const r = 1 / (one.x - two.x);\n const b = Math.pow(p, r);\n const a = one.y / Math.pow(b, one.x);\n return { a, b };\n};\n\n/**\n * y=a*(b)^x\n */\nexport const exponential = (a, b) => (x) => a * Math.pow(b, x);\n\n/**\n * Generate a set of data points, add spacing before min and after max if there is space between minx + min and maxX and max\n * @param {*} domain\n * @param {*} range\n * @param {*} root\n * @param {*} edge\n * @param {*} yFn\n * @param {*} excludeOutsidePoints\n */\nexport const buildDataPoints = (domain, range, root, edge, yFn, excludeOutsidePoints = false) => {\n log('[buildDataPoints] domain:', domain, 'range:', range, 'root:', root, 'edge:', edge);\n\n domain = { min: 0, max: 0, step: 1, ...domain };\n range = { min: 0, max: 0, step: 1, ...range };\n edge = edge ? edge : { ...root };\n\n const minX = Math.min(root.x, edge.x);\n const xPts = xPoints(minX, domain.step, domain.min - domain.step, domain.max + domain.step);\n\n log('[buildDataPoints]:xPts:', xPts);\n\n let startIndex = -1;\n let endIndex = -1;\n\n // generate points based on the yFn\n const points = xPts.map((v) => new Point(v, yFn(v)));\n\n if (!excludeOutsidePoints) {\n return points;\n }\n\n // exclude the points with y outside range min and max\n const filteredPoints = points.reduce((acc, val, index) => {\n if (val.y >= range.min - range.step && val.y <= range.max + range.step) {\n if (startIndex === -1) {\n startIndex = index;\n }\n\n if (endIndex < index) {\n endIndex = index;\n }\n\n return [...acc, val];\n }\n\n return acc;\n }, []);\n\n // add the first value outside range min and max smaller than range.min if exists\n if (startIndex - 1 >= 0) {\n filteredPoints.unshift(points[startIndex - 1]);\n }\n\n // add the first value outside range min and max greater than range.min if exists\n if (endIndex + 1 <= points.length - 1) {\n filteredPoints.push(points[endIndex + 1]);\n }\n\n return points;\n};\n\nexport default {\n FREQ_DIVIDER,\n getAmplitudeAndFreq,\n xPoints,\n sinY,\n parabolaFromTwoPoints,\n parabolaFromThreePoints,\n pointsToABC,\n parabola,\n absoluteFromTwoPoints,\n pointsToAForAbsolute,\n absolute,\n exponentialFromTwoPoints,\n pointsToABForExponential,\n exponential,\n buildDataPoints,\n};\n"],"file":"index.js"}
|