@pie-element/graphing 11.0.4-next.20261011174919 → 11.0.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.
@@ -1,111 +1,98 @@
1
1
  import { differenceWith as e, isEqual as t, uniq as n, uniqWith as r } from "@pie-element/shared-lodash";
2
2
  import { getAmplitudeAndFreq as i, pointsToABC as a, pointsToABForExponential as o, pointsToAForAbsolute as s } from "@pie-lib/graphing-utils";
3
3
  //#region src/controller/utils.ts
4
- var c = (e, n) => (e = { ...e }, n = { ...n }, t(e.x, n.x) && t(e.y, n.y)), l = (e, n) => {
4
+ var c = (e) => ({ ...e }), l = (e, n) => (e = { ...e }, n = { ...n }, t(e.x, n.x) && t(e.y, n.y)), u = (e, n) => {
5
5
  let r = !0;
6
6
  return e = { ...e }, n = { ...n }, (e.label || n.label) && (r = t(e.label, n.label)), t(e.x, n.x) && t(e.y, n.y) && r;
7
- }, u = (e, n) => t(e.from, n.from) && t(e.to, n.to) || t(e.to, n.from) && t(e.from, n.to), d = (e, n) => t(e.from, n.from) && t(e.to, n.to), f = (e) => Object.keys(e || {}).sort().reduce((t, n) => (n !== "correctAnswer" && (t[n] = e[n]), t), {}), p = (e) => {
8
- e = {
9
- ...e,
10
- to: { ...e.to },
11
- from: { ...e.from }
12
- };
13
- let t = e.from.x, n = e.from.y, r = e.to.x, i = e.to.y;
7
+ }, d = (e, n) => t(e.from, n.from) && t(e.to, n.to) || t(e.to, n.from) && t(e.from, n.to), f = (e, n) => t(e.from, n.from) && t(e.to, n.to), p = (e) => Object.keys(e || {}).sort().reduce((t, n) => (e && n !== "correctAnswer" && (t[n] = e[n]), t), {}), m = (e) => {
8
+ let t = c(e.from), n = c(e.to), r = t.x, i = t.y, a = n.x, o = n.y;
14
9
  return {
15
- a: i - n,
16
- b: t - r,
17
- c: r * n - t * i
10
+ a: o - i,
11
+ b: r - a,
12
+ c: a * i - r * o
18
13
  };
19
- }, m = (e) => Math.round(e * 1e4) / 1e4, h = (e, t) => {
20
- let { a: r, b: i, c: a } = p(e), { a: o, b: s, c } = p(t), l = [];
21
- if (o !== 0) l.push(m(r / o));
14
+ }, h = (e) => Math.round(e * 1e4) / 1e4, g = (e, t) => {
15
+ let { a: r, b: i, c: a } = m(e), { a: o, b: s, c } = m(t), l = [];
16
+ if (o !== 0) l.push(h(r / o));
22
17
  else if (r !== o) return !1;
23
- if (s !== 0) l.push(m(i / s));
18
+ if (s !== 0) l.push(h(i / s));
24
19
  else if (i !== s) return !1;
25
- if (c !== 0) l.push(m(a / c));
20
+ if (c !== 0) l.push(h(a / c));
26
21
  else if (a !== c) return !1;
27
22
  return n(l).length === 1;
28
- }, g = (e, t) => {
29
- e = {
30
- ...e,
31
- to: { ...e.to },
32
- from: { ...e.from }
33
- }, t = {
34
- ...t,
35
- to: { ...t.to },
36
- from: { ...t.from }
23
+ }, _ = (e, t) => {
24
+ let n = {
25
+ from: c(e.from),
26
+ to: c(e.to)
27
+ }, r = {
28
+ from: c(t.from),
29
+ to: c(t.to)
30
+ }, i = (n.to.y - n.from.y) / (n.to.x - n.from.x), a = (r.to.y - r.from.y) / (r.to.x - r.from.x), o = Math.atan2(n.to.y - n.from.y, n.to.x - n.from.x) * 180 / Math.PI, s = Math.atan2(r.to.y - r.from.y, r.to.x - r.from.x) * 180 / Math.PI;
31
+ return i === a && n.from.x === r.from.x && n.from.y === r.from.y && o === s;
32
+ }, v = (e) => {
33
+ let t = e || [];
34
+ return t.map((e, n) => ({
35
+ from: e,
36
+ to: t[(n + 1) % t.length]
37
+ }));
38
+ }, y = (e) => (e ||= [], r(e, (e, t) => d(e, t))), b = (e) => (e ||= [], e.filter((e) => !t(e.from, e.to))), x = (t, n) => {
39
+ let { points: r } = t, { points: i } = n, a = v(r), o = v(i), s = y(b(a)), c = y(b(o)), l = e(s, c, d), u = e(c, s, d);
40
+ return (!l || !l.length) && (!u || !u.length);
41
+ }, S = (e, n) => {
42
+ let r = {
43
+ root: c(e.root),
44
+ edge: c(e.edge)
45
+ }, i = {
46
+ root: c(n.root),
47
+ edge: c(n.edge)
37
48
  };
38
- let n = (e.to.y - e.from.y) / (e.to.x - e.from.x), r = (t.to.y - t.from.y) / (t.to.x - t.from.x), i = Math.atan2(e.to.y - e.from.y, e.to.x - e.from.x) * 180 / Math.PI, a = Math.atan2(t.to.y - t.from.y, t.to.x - t.from.x) * 180 / Math.PI;
39
- return n === r && e.from.x === t.from.x && e.from.y === t.from.y && i === a;
40
- }, _ = (e) => (e || []).map((t, n) => ({
41
- from: t,
42
- to: e[(n + 1) % e.length]
43
- })), v = (e) => (e ||= [], r(e, (e, t) => u(e, t))), y = (e) => (e ||= [], e.filter((e) => !t(e.from, e.to))), b = (t, n) => {
44
- let { points: r } = t, { points: i } = n, a = _(r), o = _(i), s = v(y(a)), c = v(y(o)), l = e(s, c, u), d = e(c, s, u);
45
- return (!l || !l.length) && (!d || !d.length);
46
- }, x = (e, n) => {
47
- if (e = {
48
- ...e,
49
- root: { ...e.root },
50
- edge: { ...e.edge }
51
- }, n = {
52
- ...n,
53
- root: { ...n.root },
54
- edge: { ...n.edge }
55
- }, t(n.edge, e.edge) && t(n.root, e.root)) return !0;
56
- let r = Math.sqrt((e.edge.x - e.root.x) ** 2 + (e.edge.y - e.root.y) ** 2), i = Math.sqrt((n.edge.x - n.root.x) ** 2 + (n.edge.y - n.root.y) ** 2);
57
- return t(n.root, e.root) && t(r, i);
58
- }, S = (e, t) => {
59
- let n = ({ root: e, edge: t }) => {
60
- e = { ...e }, t = { ...t };
61
- let { amplitude: n, freq: r } = i(e, t), a = Math.abs(e.y - t.y) * 2, o = Math.abs(e.x - t.x) * 2, s = t.x, c = t.y;
62
- for (; s < 0 && o !== 0;) s += o, c = c < e.y ? c + a : c - a;
63
- for (; s - o > 0 && o !== 0;) s -= o, c = c < e.y ? c + a : c - a;
49
+ if (t(i.edge, r.edge) && t(i.root, r.root)) return !0;
50
+ let a = Math.sqrt((r.edge.x - r.root.x) ** 2 + (r.edge.y - r.root.y) ** 2), o = Math.sqrt((i.edge.x - i.root.x) ** 2 + (i.edge.y - i.root.y) ** 2);
51
+ return t(i.root, r.root) && t(a, o);
52
+ }, C = (e, t) => {
53
+ let n = (e) => {
54
+ let t = c(e.root), n = c(e.edge), { amplitude: r, freq: a } = i(t, n), o = Math.abs(t.y - n.y) * 2, s = Math.abs(t.x - n.x) * 2, l = n.x, u = n.y;
55
+ for (; l < 0 && s !== 0;) l += s, u = u < t.y ? u + o : u - o;
56
+ for (; l - s > 0 && s !== 0;) l -= s, u = u < t.y ? u + o : u - o;
64
57
  return {
65
- amplitude: m(n),
66
- freq: m(r),
67
- min: m(t.y < e.y ? t.y : t.y - a),
68
- max: m(t.y < e.y ? t.y + a : t.y),
69
- edgeAboveZeroX: m(s),
70
- edgeAboveZeroY: m(c)
58
+ amplitude: h(r),
59
+ freq: h(a),
60
+ min: h(n.y < t.y ? n.y : n.y - o),
61
+ max: h(n.y < t.y ? n.y + o : n.y),
62
+ edgeAboveZeroX: h(l),
63
+ edgeAboveZeroY: h(u)
71
64
  };
72
- }, r = n(e), a = n(t), { amplitude: o, freq: s, min: c, max: l, edgeAboveZeroX: u, edgeAboveZeroY: d } = r, { amplitude: f, freq: p, min: h, max: g, edgeAboveZeroX: _, edgeAboveZeroY: v } = a;
73
- return Math.abs(o) === Math.abs(f) && Math.abs(s) === Math.abs(p) && c === h && l === g && u === _ && d === v;
74
- }, C = (e, t) => {
75
- let { edge: n } = e, { edge: r } = t, { root: i } = e, { root: o } = t;
76
- i = { ...i }, o = { ...o };
77
- let s = n || { ...i }, c = r || { ...o }, l = {
65
+ }, r = n(e), a = n(t), { amplitude: o, freq: s, min: l, max: u, edgeAboveZeroX: d, edgeAboveZeroY: f } = r, { amplitude: p, freq: m, min: g, max: _, edgeAboveZeroX: v, edgeAboveZeroY: y } = a;
66
+ return Math.abs(o) === Math.abs(p) && Math.abs(s) === Math.abs(m) && l === g && u === _ && d === v && f === y;
67
+ }, w = (e, t) => {
68
+ let { edge: n } = e, { edge: r } = t, i = c(e.root), o = c(t.root), s = n || { ...i }, l = r || { ...o }, u = {
78
69
  x: i.x - (s.x - i.x),
79
70
  y: s.y
80
- }, u = {
81
- x: o.x - (c.x - o.x),
82
- y: c.y
71
+ }, d = {
72
+ x: o.x - (l.x - o.x),
73
+ y: l.y
83
74
  };
84
75
  if (!n || !r) return !1;
85
- let { a: d, b: f, c: p } = a(i, n, l), { a: m, b: h, c: g } = a(o, r, u), _ = (e) => Math.round(e * 1e4) / 1e4;
86
- return _(d) === _(m) && _(f) === _(h) && _(p) === _(g);
87
- }, w = (e, n) => {
88
- let { edge: r } = e, { edge: i } = n, { root: a } = e, { root: o } = n;
89
- a = { ...a }, o = { ...o };
90
- let c = r || { ...a }, l = i || { ...o }, u = s(a, c), d = s(o, l);
91
- return t(o, a) && t(d, u);
76
+ let { a: f, b: p, c: m } = a(i, n, u), { a: h, b: g, c: _ } = a(o, r, d), v = (e) => Math.round(e * 1e4) / 1e4;
77
+ return v(f) === v(h) && v(p) === v(g) && v(m) === v(_);
92
78
  }, T = (e, n) => {
93
- let { edge: r } = e, { edge: i } = n, { root: a } = e, { root: s } = n;
94
- a = { ...a }, s = { ...s };
95
- let c = r || { ...a }, l = i || { ...s }, { a: u, b: d } = o(a, c), { a: f, b: p } = o(s, l);
96
- return t(f, u) && t(p, d);
97
- }, E = {
98
- circle: (e, t) => x(e, t),
99
- line: (e, t) => h(e, t),
100
- parabola: (e, t) => C(e, t),
101
- absolute: (e, t) => w(e, t),
102
- exponential: (e, t) => T(e, t),
103
- point: (e, t) => c(e, t),
104
- polygon: (e, t) => b(e, t),
105
- ray: (e, t) => g(e, t),
106
- segment: (e, t) => u(e, t),
107
- sine: (e, t) => S(e, t),
108
- vector: (e, t) => d(e, t)
79
+ let { edge: r } = e, { edge: i } = n, a = c(e.root), o = c(n.root), l = r || { ...a }, u = i || { ...o }, d = s(a, l), f = s(o, u);
80
+ return t(o, a) && t(f, d);
81
+ }, E = (e, n) => {
82
+ let { edge: r } = e, { edge: i } = n, a = c(e.root), s = c(n.root), l = r || { ...a }, u = i || { ...s }, { a: d, b: f } = o(a, l), { a: p, b: m } = o(s, u);
83
+ return t(p, d) && t(m, f);
84
+ }, D = {
85
+ circle: (e, t) => S(e, t),
86
+ line: (e, t) => g(e, t),
87
+ parabola: (e, t) => w(e, t),
88
+ absolute: (e, t) => T(e, t),
89
+ exponential: (e, t) => E(e, t),
90
+ point: (e, t) => l(e, t),
91
+ polygon: (e, t) => x(e, t),
92
+ ray: (e, t) => _(e, t),
93
+ segment: (e, t) => d(e, t),
94
+ sine: (e, t) => C(e, t),
95
+ vector: (e, t) => f(e, t)
109
96
  };
110
97
  //#endregion
111
- export { _ as constructSegmentsFromPoints, w as equalAbsolute, x as equalCircle, T as equalExponential, h as equalLine, E as equalMarks, C as equalParabola, c as equalPoint, l as equalPointWithLabel, b as equalPolygon, g as equalRay, u as equalSegment, S as equalSine, d as equalVector, v as removeDuplicateSegments, y as removeInvalidSegments, f as sortedAnswers };
98
+ export { v as constructSegmentsFromPoints, T as equalAbsolute, S as equalCircle, E as equalExponential, g as equalLine, D as equalMarks, w as equalParabola, l as equalPoint, u as equalPointWithLabel, x as equalPolygon, _ as equalRay, d as equalSegment, C as equalSine, f as equalVector, y as removeDuplicateSegments, b as removeInvalidSegments, p as sortedAnswers };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { default } from './delivery/index.js';
2
+ export type * from './types.js';