plotboilerplate 1.23.2 → 1.23.3

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 (101) hide show
  1. package/dist/index.esm.js +7052 -6754
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +329 -27
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +4 -2
  10. package/src/cjs/PlotBoilerplate.d.ts +4 -2
  11. package/src/cjs/PlotBoilerplate.js +7 -3
  12. package/src/cjs/PlotBoilerplate.js.map +1 -1
  13. package/src/cjs/Polygon.d.ts +107 -4
  14. package/src/cjs/Polygon.js +215 -9
  15. package/src/cjs/Polygon.js.map +1 -1
  16. package/src/cjs/Triangle.d.ts +23 -3
  17. package/src/cjs/Triangle.js +15 -2
  18. package/src/cjs/Triangle.js.map +1 -1
  19. package/src/cjs/VertTuple.d.ts +12 -7
  20. package/src/cjs/VertTuple.js +14 -9
  21. package/src/cjs/VertTuple.js.map +1 -1
  22. package/src/cjs/Vertex.d.ts +2 -1
  23. package/src/cjs/Vertex.js +5 -2
  24. package/src/cjs/Vertex.js.map +1 -1
  25. package/src/cjs/draw.d.ts +1 -0
  26. package/src/cjs/draw.js +2 -1
  27. package/src/cjs/draw.js.map +1 -1
  28. package/src/cjs/drawutilssvg.js +24 -0
  29. package/src/cjs/drawutilssvg.js.map +1 -1
  30. package/src/cjs/geomutils.d.ts +32 -1
  31. package/src/cjs/geomutils.js +47 -1
  32. package/src/cjs/geomutils.js.map +1 -1
  33. package/src/cjs/utils/algorithms/PolygonInset.d.ts +184 -0
  34. package/src/cjs/utils/algorithms/PolygonInset.js +431 -0
  35. package/src/cjs/utils/algorithms/PolygonInset.js.map +1 -0
  36. package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
  37. package/src/cjs/utils/algorithms/clearDuplicateVertices.js +6 -3
  38. package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  39. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
  40. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js +3 -3
  41. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  42. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
  43. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
  44. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  45. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  46. package/src/cjs/utils/dom/guiSizeToggler.d.ts +2 -1
  47. package/src/cjs/utils/dom/guiSizeToggler.js +5 -3
  48. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  49. package/src/esm/PlotBoilerplate.d.ts +4 -2
  50. package/src/esm/PlotBoilerplate.js +7 -3
  51. package/src/esm/PlotBoilerplate.js.map +1 -1
  52. package/src/esm/Polygon.d.ts +107 -4
  53. package/src/esm/Polygon.js +214 -9
  54. package/src/esm/Polygon.js.map +1 -1
  55. package/src/esm/Triangle.d.ts +23 -3
  56. package/src/esm/Triangle.js +15 -2
  57. package/src/esm/Triangle.js.map +1 -1
  58. package/src/esm/VertTuple.d.ts +12 -7
  59. package/src/esm/VertTuple.js +14 -9
  60. package/src/esm/VertTuple.js.map +1 -1
  61. package/src/esm/Vertex.d.ts +2 -1
  62. package/src/esm/Vertex.js +5 -2
  63. package/src/esm/Vertex.js.map +1 -1
  64. package/src/esm/draw.d.ts +1 -0
  65. package/src/esm/draw.js +2 -1
  66. package/src/esm/draw.js.map +1 -1
  67. package/src/esm/drawutilssvg.js +24 -0
  68. package/src/esm/drawutilssvg.js.map +1 -1
  69. package/src/esm/geomutils.d.ts +32 -1
  70. package/src/esm/geomutils.js +47 -1
  71. package/src/esm/geomutils.js.map +1 -1
  72. package/src/esm/utils/algorithms/PolygonInset.d.ts +184 -0
  73. package/src/esm/utils/algorithms/PolygonInset.js +424 -0
  74. package/src/esm/utils/algorithms/PolygonInset.js.map +1 -0
  75. package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
  76. package/src/esm/utils/algorithms/clearDuplicateVertices.js +6 -3
  77. package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  78. package/src/esm/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
  79. package/src/esm/utils/algorithms/findPolygonSelfIntersections.js +3 -3
  80. package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  81. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
  82. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
  83. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  84. package/src/esm/utils/detectDarkMode.js.map +1 -1
  85. package/src/esm/utils/dom/guiSizeToggler.d.ts +2 -1
  86. package/src/esm/utils/dom/guiSizeToggler.js +4 -2
  87. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  88. package/src/ts/PlotBoilerplate.ts +7 -3
  89. package/src/ts/Polygon.ts +230 -9
  90. package/src/ts/Triangle.ts +18 -4
  91. package/src/ts/VertTuple.ts +15 -10
  92. package/src/ts/Vertex.ts +5 -2
  93. package/src/ts/draw.ts +2 -1
  94. package/src/ts/drawutilssvg.ts +29 -0
  95. package/src/ts/geomutils.ts +49 -1
  96. package/src/ts/utils/algorithms/PolygonInset.ts +529 -0
  97. package/src/ts/utils/algorithms/clearDuplicateVertices.ts +11 -8
  98. package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts +25 -26
  99. package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts +92 -99
  100. package/src/ts/utils/detectDarkMode.ts +1 -3
  101. package/src/ts/utils/dom/guiSizeToggler.ts +4 -2
@@ -2,16 +2,47 @@
2
2
  * @author Ikaros Kappler
3
3
  * @date 2019-02-03
4
4
  * @modified 2021-03-01 Added `wrapMax` function.
5
- * @version 1.1.0
5
+ * @modified 2024-11-15 Adding helper function `geomutils.mapAngleTo2PI(number)` for mapping any value into the interval [0,2*PI).
6
+ * @modified 2024-11-22 Adding helper function `geomutils.dotProduct(number)` for calculating the dot product of two vertices (as vectors).
7
+ *
8
+ * @version 1.2.0
6
9
  **/
7
10
  import { Line } from "./Line";
8
11
  import { Vertex } from "./Vertex";
12
+ import { XYCoords } from "./interfaces";
9
13
  /**
10
14
  * A collection of usefull geometry utilities.
11
15
  *
12
16
  * @global
13
17
  **/
14
18
  export declare const geomutils: {
19
+ /**
20
+ * Map any angle (any numeric value) to [0, Math.PI).
21
+ *
22
+ * @param {number} angle - The numeric value to map.
23
+ * @return {number} The mapped angle inside [0,PI*2].
24
+ **/
25
+ mapAngleTo2PI(angle: number): number;
26
+ /**
27
+ * Calculate the euclidean distance between two points given by four coordinates (two coordinates each).
28
+ *
29
+ * @param {number} x1
30
+ * @param {number} y1
31
+ * @param {number} x2
32
+ * @param {number} y2
33
+ * @returns {number}
34
+ */
35
+ dist4(x1: number, y1: number, x2: number, y2: number): number;
36
+ /**
37
+ * Map any angle (any numeric value) to [0, Math.PI).
38
+ *
39
+ * A × B := (A.x * B.x) + (A.y * B.y)
40
+ *
41
+ * @param {XYCoords} vertA - The first vertex.
42
+ * @param {XYCoords} vertB - The second vertex.
43
+ * @return {number} The dot product of the two vertices.
44
+ **/
45
+ dotProduct(vertA: XYCoords, vertB: XYCoords): number;
15
46
  /**
16
47
  * Compute the n-section of the angle – described as a triangle (A,B,C) – in point A.
17
48
  *
@@ -3,7 +3,10 @@
3
3
  * @author Ikaros Kappler
4
4
  * @date 2019-02-03
5
5
  * @modified 2021-03-01 Added `wrapMax` function.
6
- * @version 1.1.0
6
+ * @modified 2024-11-15 Adding helper function `geomutils.mapAngleTo2PI(number)` for mapping any value into the interval [0,2*PI).
7
+ * @modified 2024-11-22 Adding helper function `geomutils.dotProduct(number)` for calculating the dot product of two vertices (as vectors).
8
+ *
9
+ * @version 1.2.0
7
10
  **/
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.geomutils = void 0;
@@ -15,6 +18,49 @@ var Triangle_1 = require("./Triangle");
15
18
  * @global
16
19
  **/
17
20
  exports.geomutils = {
21
+ /**
22
+ * Map any angle (any numeric value) to [0, Math.PI).
23
+ *
24
+ * @param {number} angle - The numeric value to map.
25
+ * @return {number} The mapped angle inside [0,PI*2].
26
+ **/
27
+ mapAngleTo2PI: function (angle) {
28
+ // Source: https://forums.codeguru.com/showthread.php?384172-get-angle-into-range-0-2*pi
29
+ var new_angle = Math.asin(Math.sin(angle));
30
+ if (Math.cos(angle) < 0) {
31
+ return Math.PI - new_angle;
32
+ }
33
+ else if (new_angle < 0) {
34
+ return new_angle + 2 * Math.PI;
35
+ }
36
+ else {
37
+ return new_angle;
38
+ }
39
+ },
40
+ /**
41
+ * Calculate the euclidean distance between two points given by four coordinates (two coordinates each).
42
+ *
43
+ * @param {number} x1
44
+ * @param {number} y1
45
+ * @param {number} x2
46
+ * @param {number} y2
47
+ * @returns {number}
48
+ */
49
+ dist4: function (x1, y1, x2, y2) {
50
+ return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y1 - y2, 2));
51
+ },
52
+ /**
53
+ * Map any angle (any numeric value) to [0, Math.PI).
54
+ *
55
+ * A × B := (A.x * B.x) + (A.y * B.y)
56
+ *
57
+ * @param {XYCoords} vertA - The first vertex.
58
+ * @param {XYCoords} vertB - The second vertex.
59
+ * @return {number} The dot product of the two vertices.
60
+ **/
61
+ dotProduct: function (vertA, vertB) {
62
+ return vertA.x * vertB.x + vertA.y * vertB.y;
63
+ },
18
64
  /**
19
65
  * Compute the n-section of the angle – described as a triangle (A,B,C) – in point A.
20
66
  *
@@ -1 +1 @@
1
- {"version":3,"file":"geomutils.js","sourceRoot":"","sources":["../ts/geomutils.ts"],"names":[],"mappings":";AAA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AAC,MAAM,EAAE,CAAC,CAAC;QACtE,IAAM,WAAW,GAAW,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAEzD,IAAI,MAAM,GAAgB,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,qCAAqC;YACrC,MAAM,CAAC,IAAI,CAAC,IAAI,WAAI,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAS,CAAC,CAAC;QACtG,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,OAAO,YAAC,CAAS,EAAE,GAAW;QAC5B,WAAW;QACX,6FAA6F;QAC7F,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,oBAAoB;IACpB,UAAU,YAAC,CAAS,EAAE,GAAW,EAAE,GAAW;QAC5C,OAAO,GAAG,GAAG,iBAAS,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IACrD,CAAC;CACF,CAAC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Calculate the inset of any non-self-overlapping polygon.
3
+ *
4
+ * The polygon may be
5
+ * - convex or non-convex
6
+ * - self-intersecting
7
+ *
8
+ * The algorithms will
9
+ * - first construct a general offset polygon which may be corrupt due to ouf-of-bounds or in illegal-area problems.
10
+ * - then dissect the possibly self-intersecting inset polygon into separate simple polygons.
11
+ * - then detect for each if it's out of bounds or in some illegal area.
12
+ * - keeping only the valid ones.
13
+ *
14
+ * @required sutherlandHodgman
15
+ * @required splitPolygonToNonIntersecting
16
+ *
17
+ * @author Ikaros Kappler
18
+ * @date 2024-11-04 Ported the script to a class.
19
+ * @modified 2024-12-02 Ported to Typescript.
20
+ */
21
+ import { Line } from "../../Line";
22
+ import { Polygon } from "../../Polygon";
23
+ import { Vertex } from "../../Vertex";
24
+ export interface IPolygonInsetOptions {
25
+ innerPolygonOffset: number;
26
+ maxPolygonSplitDepth?: number;
27
+ intersectionEpsilon?: number;
28
+ removeEars?: boolean;
29
+ }
30
+ export declare class PolygonInset {
31
+ /**
32
+ * The polygon to work with.
33
+ */
34
+ readonly polygon: Polygon;
35
+ /**
36
+ * The input polygon, but without ear edges.
37
+ */
38
+ optimizedPolygon: Polygon;
39
+ /**
40
+ * The original polygon as a sequence of line objects. This is easier to use than a list of points.
41
+ */
42
+ originalPolygonLines: Array<Line>;
43
+ /**
44
+ * The simple inset lines, directly generated by offsetting the original polygon lines by the given amount.
45
+ */
46
+ insetLines: Array<Line>;
47
+ /**
48
+ * The cropped inset lines that makes up the first direct iteration of the inset polygon.
49
+ * This one will probably be self-intersecting.
50
+ */
51
+ insetPolygonLines: Array<Line>;
52
+ /**
53
+ * The inset polygon lines resembling an actual polygon instance (not just a sequence of lines).
54
+ */
55
+ insetPolygon: Polygon;
56
+ /**
57
+ * Each polygon line and it's offsetted inset-line resemble a rectangular polygon.
58
+ * Array<Polygon> with 4 vertices each
59
+ **/
60
+ insetRectanglePolygons: Array<Polygon>;
61
+ /**
62
+ * The inset polygon split up into simple non-self-intersecting polygons.
63
+ * Represented as a list of vertex-lists. Each sub-list represents a single polygon.
64
+ */
65
+ splitPolygons: Array<Array<Vertex>>;
66
+ /**
67
+ * The final result: all valid split-polygons. These are making up the actual polygon inset.
68
+ * Note: list may be empty. Depending on the offset amount there is not a guaranteed offset polygon existing.
69
+ */
70
+ filteredSplitPolygons: Array<Array<Vertex>>;
71
+ /**
72
+ * Constructs a new PolygonInset instance with the underlying given polygon to work with.
73
+ *
74
+ * Please note that the algorithm will reverse the vertex order if the given polygon
75
+ * is not clockwise.
76
+ *
77
+ * @param {Polygon} polygon - The polygon to calculate the offset for.
78
+ */
79
+ constructor(polygon: Polygon);
80
+ /**
81
+ * This is the main method.
82
+ *
83
+ * Call this with the required option params to compute your desired offset polygon(s).
84
+ *
85
+ * @param {number} options.innerPolygonOffset - The offset to use. Should be a positive number. Correct result for negative numbers are not guaranteed.
86
+ * @param {number?} options.maxPolygonSplitDepth - (default is the number of polygon.vertices) The maximum amount of recursive stepts to simplify the complex first iteration of the offset polygon.
87
+ * @param {number?} options.intersectionEpsilon - (default is 1.0) The epsilon to use for detecting overlapping polygons. This indicates a tolerance value, because directly adjecent polygons may have a little arithmetic intersection area.
88
+ * @returns {Array<Array<Vertex>>} A list of vertex-lists, each one representing a simple polygon from the offset-polygons.
89
+ */
90
+ computeOutputPolygons(options: IPolygonInsetOptions): Array<Array<Vertex>>;
91
+ /**
92
+ * This method transforms each polygon line into a new line
93
+ * by moving it to the inside direction of the polygon (by the given `insetAmount`).
94
+ *
95
+ * @param {Array<Line>} polygonLines
96
+ * @param {number} insetAmount
97
+ * @return {Array<Line>} The transformed lines. The result array has the same length and order as the input array.
98
+ */
99
+ private _collectInsetLines;
100
+ /**
101
+ * For a sequence of inset polygon lines get the inset polygon by detecting
102
+ * useful intersections (by cropping or extending them).
103
+ *
104
+ * The returned lines resemble a new polygon.
105
+ *
106
+ * Please note that the returned polygon can be self-intersecting!
107
+ *
108
+ * @param {Array<Line>} insetLines
109
+ * @returns {Array<Line>} The cropped or exented inset polygon lines.
110
+ */
111
+ private _collectInsetPolygonLines;
112
+ /**
113
+ * Converts two lists (same length) of original polygon lines and inset lines (interpreted as
114
+ * pairs) to a list of rectangular polyons.
115
+ *
116
+ * @static
117
+ * @param {Array<Line>} originalPolygonLines
118
+ * @param {Array<Line>} insetLines
119
+ * @returns {Array<Polygon>} A list of rectangular polygons; each returned polyon has exactly four vertices.
120
+ */
121
+ private _collectRectangularPolygonInsets;
122
+ /**
123
+ * Converts a sequence of (hopefully adjacent) lines to a polygon by using all second line vertices `b`.
124
+ *
125
+ * @static
126
+ * @param insetPolygonLines
127
+ * @returns
128
+ */
129
+ private static convertToBasicInsetPolygon;
130
+ /**
131
+ * Optimize the inset polygon by removing critical `ear` edges.
132
+ * Such an is identified by: the edge itself is completely located inside its neighbours inset rectangle.
133
+ *
134
+ * In this process multiple edges from the ear might be dropped and two adjacent edges get a new
135
+ * common intersection point.
136
+ *
137
+ * Note: this method is not working as expected in all cases and quite experimental.
138
+ *
139
+ * @param insetPolygon
140
+ * @param insetRectangles
141
+ */
142
+ private static _optimizeInsetPolygon;
143
+ private static _locateExcessiveEarEdge;
144
+ private static _rectangleFullyContainsLine;
145
+ /**
146
+ * Filter split polygons: only keep those whose vertices are all contained inside the original polygon.
147
+ * Reason: scaling too much will result in excessive translation beyond the opposite bounds of the polygon (like more than 200% of possible insetting).
148
+ *
149
+ * @param {Array<Array<Vertex>>} splitPolygonsVertices
150
+ * @param {Polygon} originalPolygon
151
+ * @return {Array<Array<Vertex>>} The filtered polygon list.
152
+ */
153
+ private static _filterInnerSplitPolygonsByOriginalBounds;
154
+ /**
155
+ * Filter split polygons: only keep those that do not (signifiantly) interset with any rectangles.
156
+ *
157
+ * @static
158
+ * @param {Array<Array<Vertex>>} splitPolygonsVertices
159
+ * @param {Array<Polygon>} insetRectanglePolygons
160
+ * @param {number?=1.0} intersectionEpsilon - (optional, default is 1.0) A epsislon to define a tolerance for checking if two polygons intersect.
161
+ */
162
+ private static _filterInnerSplitPolygonsByCoverage;
163
+ /**
164
+ * This private method will reverse each polygon's vertex order that's not clockwise.
165
+ *
166
+ * @param {Array<Vertex[]>} polygons
167
+ */
168
+ private static _assertAllPolygonsAreClockwise;
169
+ /**
170
+ * This private method will revert the vertex order if the polygon is not clockwise.
171
+ *
172
+ * @param {Vertex[]} polygonVerts
173
+ */
174
+ private static _assertPolygonIsClockwise;
175
+ /**
176
+ * For simplification I'm using a callback generator function here.
177
+ *
178
+ * @param splitPolyVerts
179
+ * @param eps
180
+ * @param _splitPolyIndex
181
+ * @returns {Function} The callback for an `Array.some` parameter.
182
+ */
183
+ private static _hasIntersectionCallback;
184
+ }