plotboilerplate 1.30.0 → 1.31.0

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 (58) hide show
  1. package/README.md +26 -13
  2. package/dist/index.esm.js +120 -45
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +75 -24
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cjs/Polygon.d.ts +18 -4
  12. package/src/cjs/Polygon.js +56 -18
  13. package/src/cjs/Polygon.js.map +1 -1
  14. package/src/cjs/VertTuple.d.ts +15 -4
  15. package/src/cjs/VertTuple.js +17 -4
  16. package/src/cjs/VertTuple.js.map +1 -1
  17. package/src/cjs/Vertex.d.ts +2 -2
  18. package/src/cjs/Vertex.js +2 -2
  19. package/src/cjs/utils/algorithms/delaunay2voronoi.d.ts +2 -1
  20. package/src/cjs/utils/algorithms/delaunay2voronoi.js +8 -10
  21. package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
  22. package/src/cjs/utils/datastructures/PointSet.d.ts +63 -0
  23. package/src/cjs/utils/datastructures/PointSet.js +126 -0
  24. package/src/cjs/utils/datastructures/PointSet.js.map +1 -0
  25. package/src/cjs/utils/datastructures/VoronoiCell.d.ts +19 -2
  26. package/src/cjs/utils/datastructures/VoronoiCell.js +39 -12
  27. package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
  28. package/src/cjs/utils/renderers/VoronoiRenderer.d.ts +99 -0
  29. package/src/cjs/utils/renderers/VoronoiRenderer.js +147 -0
  30. package/src/cjs/utils/renderers/VoronoiRenderer.js.map +1 -0
  31. package/src/esm/Polygon.d.ts +18 -4
  32. package/src/esm/Polygon.js +56 -18
  33. package/src/esm/Polygon.js.map +1 -1
  34. package/src/esm/VertTuple.d.ts +15 -4
  35. package/src/esm/VertTuple.js +17 -4
  36. package/src/esm/VertTuple.js.map +1 -1
  37. package/src/esm/Vertex.d.ts +2 -2
  38. package/src/esm/Vertex.js +2 -2
  39. package/src/esm/utils/algorithms/delaunay2voronoi.d.ts +2 -1
  40. package/src/esm/utils/algorithms/delaunay2voronoi.js +8 -10
  41. package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
  42. package/src/esm/utils/datastructures/PointSet.d.ts +63 -0
  43. package/src/esm/utils/datastructures/PointSet.js +115 -0
  44. package/src/esm/utils/datastructures/PointSet.js.map +1 -0
  45. package/src/esm/utils/datastructures/VoronoiCell.d.ts +19 -2
  46. package/src/esm/utils/datastructures/VoronoiCell.js +39 -12
  47. package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
  48. package/src/esm/utils/renderers/VoronoiRenderer.d.ts +99 -0
  49. package/src/esm/utils/renderers/VoronoiRenderer.js +142 -0
  50. package/src/esm/utils/renderers/VoronoiRenderer.js.map +1 -0
  51. package/src/ts/Polygon.ts +58 -18
  52. package/src/ts/VertTuple.ts +18 -4
  53. package/src/ts/Vertex.ts +2 -2
  54. package/src/ts/utils/_AppContext.ts_ +22 -0
  55. package/src/ts/utils/algorithms/delaunay2voronoi.ts +81 -88
  56. package/src/ts/utils/datastructures/PointSet.ts +135 -0
  57. package/src/ts/utils/datastructures/VoronoiCell.ts +198 -169
  58. package/src/ts/utils/renderers/VoronoiRenderer.ts +200 -0
@@ -8298,14 +8298,16 @@ exports["default"] = PlotBoilerplate;
8298
8298
  * @modified 2025-04-15 Changed param of `VertTuple.moveTo` method from `Vertex` to `XYCoords`.
8299
8299
  * @modified 2025-04-15 Added method `VertTuple.move` method.
8300
8300
  * @modified 2026-06-10 Adding helper function `VertTuple.utils.calcCircumcircle`.
8301
- * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting Vector to Line instances.
8302
- * @version 1.6.0
8301
+ * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting TertTuples to Line instances.
8302
+ * @modified 2026-09-21 Adding method `VertTuple.asVector` for converting TertTuples to Vector instances.
8303
+ * @version 1.7.0
8303
8304
  */
8304
8305
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8305
8306
  exports.VertTuple = void 0;
8306
8307
  var Vertex_1 = __webpack_require__(787);
8307
8308
  var UIDGenerator_1 = __webpack_require__(938);
8308
8309
  var Line_1 = __webpack_require__(939);
8310
+ var Vector_1 = __webpack_require__(30);
8309
8311
  /**
8310
8312
  * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.
8311
8313
  * @abstract
@@ -8597,16 +8599,27 @@ var VertTuple = /** @class */ (function () {
8597
8599
  return this.factory(this.a.clone(), this.b.clone());
8598
8600
  };
8599
8601
  /**
8600
- * Converts this `Vector` to a `Line` (segment).
8602
+ * Converts this `VertTuple` to a `Line` (segment).
8601
8603
  *
8602
8604
  * @method asLine
8603
- * @return {T} A type safe clone if this instance.
8605
+ * @return {Line} This tuple as `Line` instance.
8604
8606
  * @instance
8605
8607
  * @memberof VertTuple
8606
8608
  **/
8607
8609
  VertTuple.prototype.asLine = function () {
8608
8610
  return new Line_1.Line(this.a, this.b);
8609
8611
  };
8612
+ /**
8613
+ * Converts this `VertTuple` to a `Vector` (arrow).
8614
+ *
8615
+ * @method asVector
8616
+ * @return {Line} This tuple as `Vector` instance.
8617
+ * @instance
8618
+ * @memberof VertTuple
8619
+ **/
8620
+ VertTuple.prototype.asVector = function () {
8621
+ return new Vector_1.Vector(this.a, this.b);
8622
+ };
8610
8623
  /**
8611
8624
  * Create a string representation of this line.
8612
8625
  *
@@ -9177,7 +9190,9 @@ exports.PBText = PBText;
9177
9190
  * @modified 2025-05-16 Class `Polygon` now implements `IBounded`.
9178
9191
  * @modified 2025-05-20 Tweaking `Polygon.getInnerAngleAt` and `Polygo.isAngleAcute` to handle indices out of array bounds as well.
9179
9192
  * @modified 2025-06-07 Adding `Polygon.closestLineIntersectionIndex` to determine line intersections plus detected edge index.
9180
- * @version 1.16.0
9193
+ * @modified 2026-09-16 Adding a `forceClockwise` parameter to the `Polygon.getCentroid()` method.
9194
+ * @modified 2026-09-21 Adding `Polygon.revert` method to change the winding order.
9195
+ * @version 1.17.0
9181
9196
  *
9182
9197
  * @file Polygon
9183
9198
  * @public
@@ -9482,6 +9497,20 @@ var Polygon = /** @class */ (function () {
9482
9497
  // return Polygon.utils.signedArea(this.vertices) < 0;
9483
9498
  return Polygon.utils.isClockwise(this.vertices);
9484
9499
  };
9500
+ /**
9501
+ * Revert the order of this polygon's vertices to change the winding order.
9502
+ * This operation is in-place.
9503
+ *
9504
+ * @method revert
9505
+ * @instance
9506
+ * @memberof Polygon
9507
+ * @return {Polygon} This for chaining.
9508
+ */
9509
+ Polygon.prototype.revert = function () {
9510
+ // this.vertices.slice().reverse(); // Copy?
9511
+ this.vertices.reverse();
9512
+ return this;
9513
+ };
9485
9514
  /**
9486
9515
  * Get the perimeter of this polygon.
9487
9516
  * The perimeter is the absolute length of the outline.
@@ -9563,35 +9592,37 @@ var Polygon = /** @class */ (function () {
9563
9592
  };
9564
9593
  /**
9565
9594
  * Get centroid.
9566
- * Centroids define the barycenter of any non self-intersecting convex polygon.
9595
+ * Centroids define the barycenter of any non self-intersecting convex clockwise polygon.
9567
9596
  *
9568
- * If the polygon is self intersecting or non konvex then the barycenter is not well defined.
9597
+ * If the polygon is self intersecting or non convex or not clockwise then the barycenter is not well defined.
9569
9598
  *
9570
9599
  * https://mathworld.wolfram.com/PolygonCentroid.html
9571
9600
  *
9572
9601
  * @method getCentroid
9573
9602
  * @instance
9603
+ * @param {boolean} forceClockwise - [optiona] If set to true then the centroid will be calculated for the clockwise polygon.
9574
9604
  * @memberof Polygon
9575
9605
  * @returns {Vertex|null}
9576
9606
  */
9577
- Polygon.prototype.getCentroid = function () {
9607
+ Polygon.prototype.getCentroid = function (forceClockwise) {
9578
9608
  if (this.vertices.length === 0) {
9579
9609
  return null;
9580
9610
  }
9581
- var center = new Vertex_1.Vertex(0.0, 0.0);
9582
- var n = this.vertices.length;
9583
- for (var i = 0; i < n; i++) {
9584
- // center.add(this.vertices[i]);
9585
- var cur = this.vertices[i];
9586
- var next = this.vertices[(i + 1) % n];
9587
- var factor = cur.x * next.y - next.x * cur.y;
9588
- center.x += (cur.x + next.x) * factor;
9589
- center.y += (cur.y + next.y) * factor;
9590
- }
9591
- var area = this.area();
9592
- center.x *= 1 / (6 * area);
9593
- center.y *= 1 / (6 * area);
9594
- return center;
9611
+ // const centroid: Vertex = new Vertex(0.0, 0.0);
9612
+ // const n = this.vertices.length;
9613
+ // for (var i = 0; i < n; i++) {
9614
+ // // center.add(this.vertices[i]);
9615
+ // const cur: Vertex = this.vertices[i];
9616
+ // const next: Vertex = this.vertices[(i + 1) % n];
9617
+ // var factor: number = cur.x * next.y - next.x * cur.y;
9618
+ // centroid.x += (cur.x + next.x) * factor;
9619
+ // centroid.y += (cur.y + next.y) * factor;
9620
+ // }
9621
+ // const area = this.area();
9622
+ // centroid.x *= 1 / (6 * area);
9623
+ // centroid.y *= 1 / (6 * area);
9624
+ // return centroid;
9625
+ return Polygon.utils.calculateCentroid(this.vertices, forceClockwise);
9595
9626
  };
9596
9627
  //--- BEGIN --- Implement interface `Intersectable`
9597
9628
  /**
@@ -10022,6 +10053,26 @@ var Polygon = /** @class */ (function () {
10022
10053
  isClockwise: function (vertices) {
10023
10054
  return Polygon.utils.signedArea(vertices) < 0;
10024
10055
  },
10056
+ calculateCentroid: function (vertices, forceClockwise) {
10057
+ var centroid = new Vertex_1.Vertex(0.0, 0.0);
10058
+ var n = vertices.length;
10059
+ if (forceClockwise && !Polygon.utils.isClockwise(vertices)) {
10060
+ return Polygon.utils.calculateCentroid(vertices.slice().reverse());
10061
+ }
10062
+ for (var i = 0; i < n; i++) {
10063
+ // center.add(this.vertices[i]);
10064
+ var cur = vertices[i];
10065
+ var next = vertices[(i + 1) % n];
10066
+ var factor = cur.x * next.y - next.x * cur.y;
10067
+ centroid.x += (cur.x + next.x) * factor;
10068
+ centroid.y += (cur.y + next.y) * factor;
10069
+ }
10070
+ // const area = this.area();
10071
+ var area = Polygon.utils.area(vertices);
10072
+ centroid.x *= 1 / (6 * area);
10073
+ centroid.y *= 1 / (6 * area);
10074
+ return centroid;
10075
+ },
10025
10076
  /**
10026
10077
  * Calulate the signed polyon area by interpreting the polygon as a matrix
10027
10078
  * and calculating its determinant.
@@ -12281,7 +12332,7 @@ exports.Triangle = Triangle;
12281
12332
  * @modified 2025-04-13 Adding the `Vertex.move(amount: XYCoords)` method (does the same as `add`, added by naming convention).
12282
12333
  * @modified 2025-05-07 Class `Vertex` is now implementing interface `IBounded` (to meet convention).
12283
12334
  * @modified 2026-06-10 Adding methods `Vertex.findClosestPoint` and `Vertex.findFarestPoint`.
12284
- * @version 2.12.0
12335
+ * @version 2.12.1
12285
12336
  *
12286
12337
  * @file Vertex
12287
12338
  * @public
@@ -12759,7 +12810,7 @@ var Vertex = /** @class */ (function () {
12759
12810
  * around given center.
12760
12811
  *
12761
12812
  * @method rotate
12762
- * @param {number} angle - The angle to 'rotate' this vertex; 0.0 means no change.
12813
+ * @param {number} angle - The angle in radians to 'rotate' this vertex; 0.0 means no change.
12763
12814
  * @param {XYCoords=} center - The center of rotation; default is (0,0).
12764
12815
  * @return {Vertex} this
12765
12816
  * @instance