flo-mat 2.0.3 → 2.0.5

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.
Files changed (43) hide show
  1. package/browser/index.js +298 -226
  2. package/browser/index.min.js +1 -1
  3. package/node/debug/functions/draw-elem/three-prong.js +1 -1
  4. package/node/debug/functions/draw-elem/two-prong.js +2 -2
  5. package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
  6. package/node/mat/closest-boundary-point/closest-points-on-curve.js +9 -6
  7. package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +1 -1
  8. package/node/mat/closest-boundary-point/get-close-boundary-points.js +0 -4
  9. package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +1 -1
  10. package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
  11. package/node/mat/find-mat/add-3-prong.js +16 -12
  12. package/node/mat/find-mat/add-3-prong.js.map +1 -1
  13. package/node/mat/find-mat/create-get-interesting-points-on-loop.js +5 -4
  14. package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +1 -1
  15. package/node/mat/find-mat/find-2-prong/find-2-prong.js +37 -7
  16. package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +1 -1
  17. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line-dd.d.ts +9 -0
  18. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line-dd.js +58 -0
  19. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -0
  20. package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
  21. package/node/mat/find-mat/get-sharp-corners.js +0 -1
  22. package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
  23. package/node/mat/is-another-cp-closeby.js +5 -16
  24. package/node/mat/is-another-cp-closeby.js.map +1 -1
  25. package/node/point-on-shape.js.map +1 -1
  26. package/package.json +14 -14
  27. package/src/debug/functions/draw-elem/three-prong.ts +1 -1
  28. package/src/debug/functions/draw-elem/two-prong.ts +2 -2
  29. package/src/mat/closest-boundary-point/closest-points-on-curve.ts +12 -8
  30. package/src/mat/closest-boundary-point/get-close-boundary-points.ts +1 -5
  31. package/src/mat/closest-boundary-point/get-closest-boundary-point-dd.ts +62 -0
  32. package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +7 -7
  33. package/src/mat/cmp-cp-on-delta.ts +3 -0
  34. package/src/mat/find-mat/add-3-prong.ts +23 -13
  35. package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +5 -4
  36. package/src/mat/find-mat/find-2-prong/find-2-prong.ts +44 -9
  37. package/src/mat/find-mat/find-2-prong/find-equidistant-point-on-line-dd.ts +79 -0
  38. package/src/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.ts +1 -1
  39. package/src/mat/find-mat/get-sharp-corners.ts +0 -1
  40. package/src/mat/is-another-cp-closeby.ts +8 -24
  41. package/src/point-on-shape.ts +2 -1
  42. package/src/mat/closest-boundary-point/closest-point-on-curve-old.ts_ +0 -88
  43. package/src/mat/closest-boundary-point/closest-point-on-curve.ts_ +0 -95
@@ -1,88 +0,0 @@
1
-
2
- import { deflate, allRootsPrecise } from 'flo-poly';
3
-
4
- import { getObjClosestTo } from 'flo-vector2d';
5
- import { evaluate, getTangentPolyFromPoint } from 'flo-bezier3';
6
-
7
- import { Curve } from "../../curve";
8
-
9
-
10
- /** @hidden */
11
- // TODO - remove delta
12
- let DELTA = 1e-11;
13
-
14
-
15
- /**
16
- * @hidden
17
- * @param curve The curve
18
- * @param p The point from which to check
19
- * @param tRange The allowed t range
20
- * @param touchedCurve The bezier on which p is located
21
- * @param t The t value of the bezier that locates p
22
- */
23
- function closestPointOnCurve(
24
- curve: Curve,
25
- p: number[],
26
- tRange: number[] = [0,1],
27
- touchedCurve?: Curve,
28
- t?: number) {
29
-
30
- let poly = getTangentPolyFromPoint(curve.ps, p);
31
-
32
- if (curve === touchedCurve) {
33
- poly = deflate(poly, t);
34
- }
35
-
36
- let roots = allRootsPrecise(poly, tRange[0], tRange[1]);
37
-
38
- // Also test the endpoints
39
- let push0 = true;
40
- let push1 = true;
41
- if ((t === 1 && curve === touchedCurve.next) ||
42
- (t === 0 && curve === touchedCurve)) {
43
- push0 = false;
44
- }
45
- if ((t === 0 && curve === touchedCurve.prev) ||
46
- (t === 1 && curve === touchedCurve)) {
47
- push1 = false;
48
- }
49
-
50
- if (tRange[0] === 0) {
51
- if (push0) { roots.push(0); }
52
- } else if (tRange[0] === 1) {
53
- if (push1) { roots.push(1); }
54
- } else {
55
- roots.push(tRange[0]);
56
- }
57
-
58
- if (tRange[1] === 0) {
59
- if (push0) { roots.push(0); }
60
- } else if (tRange[1] === 1) {
61
- if (push1) { roots.push(1); }
62
- } else {
63
- roots.push(tRange[1]);
64
- }
65
-
66
- // This is to take care of a numerical issue - see shape p1.svg.
67
- let roots_: number[] = [];
68
- for (let i=0; i<roots.length; i++) {
69
- let root = roots[i];
70
- if (root !== 0 && root < DELTA) {
71
- root = 0;
72
- } else if (root !== 1 && 1-root < DELTA) {
73
- root = 1;
74
- }
75
- roots_.push(root);
76
- }
77
-
78
- let ev = evaluate(curve.ps);
79
- let ps = roots_.map(
80
- //let ps = roots.map(
81
- root => ({ p: ev(root), t: root })
82
- );
83
-
84
- return getObjClosestTo(p, ps, p => p.p);
85
- }
86
-
87
-
88
- export { closestPointOnCurve }
@@ -1,95 +0,0 @@
1
-
2
- import { deflate, allRootsPrecise, allRootsMultiWithErrBounds, toCasStr } from 'flo-poly';
3
-
4
- import { getObjClosestTo } from 'flo-vector2d';
5
- import { evaluate, getTangentPolyFromPoint, getTangentPolyFromPointExact } from 'flo-bezier3';
6
- import { estimate } from 'flo-numerical';
7
-
8
- import { Curve } from "../../curve";
9
-
10
-
11
- /** @hidden */
12
- // TODO - remove delta
13
- let DELTA = 1e-11;
14
-
15
-
16
- /**
17
- * @hidden
18
- * @param curve The curve
19
- * @param p The point from which to check
20
- * @param tRange The allowed t range
21
- * @param touchedCurve The bezier on which p is located
22
- * @param t The t value of the bezier that locates p
23
- */
24
- function closestPointOnCurve(
25
- curve: Curve,
26
- p: number[],
27
- [tS,tE]: number[] = [0,1],
28
- touchedCurve?: Curve,
29
- t?: number) {
30
-
31
- let poly = getTangentPolyFromPointExact(curve.ps, p);
32
-
33
- //if (curve === touchedCurve) {
34
- // poly = deflate(poly, t);
35
- //}
36
-
37
- let roots = allRootsMultiWithErrBounds(
38
- poly,
39
- poly.map(c => 0), // because all coefficients are exact
40
- () => [], // ...
41
- tS,
42
- tE
43
- ).map(t => t.tM);
44
-
45
- // Also test the endpoints
46
- let push0 = true;
47
- let push1 = true;
48
- if ((t === 1 && curve === touchedCurve.next) ||
49
- (t === 0 && curve === touchedCurve)) {
50
- push0 = false;
51
- }
52
- if ((t === 0 && curve === touchedCurve.prev) ||
53
- (t === 1 && curve === touchedCurve)) {
54
- push1 = false;
55
- }
56
-
57
- if (tS === 0) {
58
- if (push0) { roots.push(0); }
59
- } else if (tS === 1) {
60
- if (push1) { roots.push(1); }
61
- } else {
62
- roots.push(tS);
63
- }
64
-
65
- if (tE === 0) {
66
- if (push0) { roots.push(0); }
67
- } else if (tE === 1) {
68
- if (push1) { roots.push(1); }
69
- } else {
70
- roots.push(tE);
71
- }
72
-
73
- // This is to take care of a numerical issue - see shape p1.svg.
74
- //let roots_: number[] = [];
75
- //for (let i=0; i<roots.length; i++) {
76
- // let root = roots[i];
77
- // if (root !== 0 && root < DELTA) {
78
- // root = 0;
79
- // } else if (root !== 1 && 1-root < DELTA) {
80
- // root = 1;
81
- // }
82
- // roots_.push(root);
83
- //}
84
-
85
- let ev = evaluate(curve.ps);
86
- //let ps = roots_.map(
87
- let ps = roots.map(
88
- root => ({ p: ev(root), t: root })
89
- );
90
-
91
- return getObjClosestTo(p, ps, p => p.p);
92
- }
93
-
94
-
95
- export { closestPointOnCurve }