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.
- package/README.md +26 -13
- package/dist/index.esm.js +120 -45
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +75 -24
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Polygon.d.ts +18 -4
- package/src/cjs/Polygon.js +56 -18
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +15 -4
- package/src/cjs/VertTuple.js +17 -4
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +2 -2
- package/src/cjs/Vertex.js +2 -2
- package/src/cjs/utils/algorithms/delaunay2voronoi.d.ts +2 -1
- package/src/cjs/utils/algorithms/delaunay2voronoi.js +8 -10
- package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/cjs/utils/datastructures/PointSet.d.ts +63 -0
- package/src/cjs/utils/datastructures/PointSet.js +126 -0
- package/src/cjs/utils/datastructures/PointSet.js.map +1 -0
- package/src/cjs/utils/datastructures/VoronoiCell.d.ts +19 -2
- package/src/cjs/utils/datastructures/VoronoiCell.js +39 -12
- package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/cjs/utils/renderers/VoronoiRenderer.d.ts +99 -0
- package/src/cjs/utils/renderers/VoronoiRenderer.js +147 -0
- package/src/cjs/utils/renderers/VoronoiRenderer.js.map +1 -0
- package/src/esm/Polygon.d.ts +18 -4
- package/src/esm/Polygon.js +56 -18
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/VertTuple.d.ts +15 -4
- package/src/esm/VertTuple.js +17 -4
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +2 -2
- package/src/esm/Vertex.js +2 -2
- package/src/esm/utils/algorithms/delaunay2voronoi.d.ts +2 -1
- package/src/esm/utils/algorithms/delaunay2voronoi.js +8 -10
- package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/esm/utils/datastructures/PointSet.d.ts +63 -0
- package/src/esm/utils/datastructures/PointSet.js +115 -0
- package/src/esm/utils/datastructures/PointSet.js.map +1 -0
- package/src/esm/utils/datastructures/VoronoiCell.d.ts +19 -2
- package/src/esm/utils/datastructures/VoronoiCell.js +39 -12
- package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/esm/utils/renderers/VoronoiRenderer.d.ts +99 -0
- package/src/esm/utils/renderers/VoronoiRenderer.js +142 -0
- package/src/esm/utils/renderers/VoronoiRenderer.js.map +1 -0
- package/src/ts/Polygon.ts +58 -18
- package/src/ts/VertTuple.ts +18 -4
- package/src/ts/Vertex.ts +2 -2
- package/src/ts/utils/_AppContext.ts_ +22 -0
- package/src/ts/utils/algorithms/delaunay2voronoi.ts +81 -88
- package/src/ts/utils/datastructures/PointSet.ts +135 -0
- package/src/ts/utils/datastructures/VoronoiCell.ts +198 -169
- package/src/ts/utils/renderers/VoronoiRenderer.ts +200 -0
package/dist/plotboilerplate.js
CHANGED
|
@@ -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
|
|
8302
|
-
* @
|
|
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 `
|
|
8602
|
+
* Converts this `VertTuple` to a `Line` (segment).
|
|
8601
8603
|
*
|
|
8602
8604
|
* @method asLine
|
|
8603
|
-
* @return {
|
|
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
|
-
* @
|
|
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
|
|
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
|
-
|
|
9582
|
-
|
|
9583
|
-
for (var i = 0; i < n; i++) {
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
return
|
|
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.
|
|
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
|