plotboilerplate 1.23.3 → 1.24.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 +6 -0
- package/dist/index.esm.js +1390 -265
- 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 +1264 -99
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/BezierPath.d.ts +41 -5
- package/src/cjs/BezierPath.js +52 -2
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Bounds.d.ts +67 -3
- package/src/cjs/Bounds.js +101 -3
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/Circle.d.ts +46 -4
- package/src/cjs/Circle.js +82 -3
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +51 -2
- package/src/cjs/CircleSector.js +112 -3
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/CubicBezierCurve.d.ts +113 -7
- package/src/cjs/CubicBezierCurve.js +281 -33
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Line.d.ts +38 -3
- package/src/cjs/Line.js +64 -1
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/PlotBoilerplate.js +2 -9
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +48 -4
- package/src/cjs/Polygon.js +91 -16
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.d.ts +52 -3
- package/src/cjs/Triangle.js +80 -1
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/VEllipse.d.ts +62 -3
- package/src/cjs/VEllipse.js +181 -17
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/VEllipseSector.d.ts +86 -2
- package/src/cjs/VEllipseSector.js +148 -4
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vector.d.ts +12 -2
- package/src/cjs/Vector.js +15 -2
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.d.ts +28 -4
- package/src/cjs/VertTuple.js +36 -3
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +17 -2
- package/src/cjs/Vertex.js +18 -1
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +39 -0
- package/src/cjs/interfaces/core.js +2 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js +14 -6
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/cjs/utils/createRandomizedPolygon.d.ts +14 -0
- package/src/cjs/utils/createRandomizedPolygon.js +32 -0
- package/src/cjs/utils/createRandomizedPolygon.js.map +1 -0
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +37 -23
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +10 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.js +19 -20
- package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/cjs/utils/helpers/VEllipseHelper.d.ts +30 -0
- package/src/cjs/utils/helpers/VEllipseHelper.js +86 -0
- package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -0
- package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js +107 -25
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/createDemoDrawables.js +3 -1
- package/src/esm/BezierPath.d.ts +41 -5
- package/src/esm/BezierPath.js +50 -2
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Bounds.d.ts +67 -3
- package/src/esm/Bounds.js +101 -3
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/Circle.d.ts +46 -4
- package/src/esm/Circle.js +79 -3
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CircleSector.d.ts +51 -2
- package/src/esm/CircleSector.js +108 -3
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/CubicBezierCurve.d.ts +113 -7
- package/src/esm/CubicBezierCurve.js +277 -33
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Line.d.ts +38 -3
- package/src/esm/Line.js +62 -1
- package/src/esm/Line.js.map +1 -1
- package/src/esm/PlotBoilerplate.js +2 -9
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +48 -4
- package/src/esm/Polygon.js +89 -16
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.d.ts +52 -3
- package/src/esm/Triangle.js +77 -1
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/VEllipse.d.ts +62 -3
- package/src/esm/VEllipse.js +178 -17
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/VEllipseSector.d.ts +86 -2
- package/src/esm/VEllipseSector.js +146 -7
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vector.d.ts +12 -2
- package/src/esm/Vector.js +15 -2
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.d.ts +28 -4
- package/src/esm/VertTuple.js +36 -3
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +17 -2
- package/src/esm/Vertex.js +18 -1
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +39 -0
- package/src/esm/interfaces/core.js +2 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.js +15 -7
- package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/esm/utils/algorithms/createRandomizedPolygon.d.ts +14 -0
- package/src/esm/utils/algorithms/createRandomizedPolygon.js +28 -0
- package/src/esm/utils/algorithms/createRandomizedPolygon.js.map +1 -0
- package/src/esm/utils/createRandomizedPolygon.d.ts +14 -0
- package/src/esm/utils/createRandomizedPolygon.js +28 -0
- package/src/esm/utils/createRandomizedPolygon.js.map +1 -0
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +35 -22
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleSectorHelper.d.ts +10 -1
- package/src/esm/utils/helpers/CircleSectorHelper.js +19 -20
- package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/esm/utils/helpers/VEllipseHelper.d.ts +30 -0
- package/src/esm/utils/helpers/VEllipseHelper.js +81 -0
- package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -0
- package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
- package/src/esm/utils/helpers/VEllipseSectorHelper.js +106 -24
- package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/ts/BezierPath.ts +58 -5
- package/src/ts/Bounds.ts +110 -6
- package/src/ts/Circle.ts +87 -5
- package/src/ts/CircleSector.ts +115 -5
- package/src/ts/CubicBezierCurve.ts +332 -42
- package/src/ts/Line.ts +66 -3
- package/src/ts/PlotBoilerplate.ts +3 -9
- package/src/ts/Polygon.ts +103 -22
- package/src/ts/Triangle.ts +85 -3
- package/src/ts/VEllipse.ts +214 -19
- package/src/ts/VEllipseSector.ts +154 -8
- package/src/ts/Vector.ts +16 -2
- package/src/ts/VertTuple.ts +39 -4
- package/src/ts/Vertex.ts +20 -2
- package/src/ts/interfaces/core.ts +42 -0
- package/src/ts/utils/algorithms/convexPolygonIncircle.ts +82 -78
- package/src/ts/utils/createRandomizedPolygon.ts +31 -0
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +45 -29
- package/src/ts/utils/helpers/CircleSectorHelper.ts +115 -125
- package/src/ts/utils/helpers/VEllipseHelper.ts +113 -0
- package/src/ts/utils/helpers/VEllipseSectorHelper.ts +142 -25
package/src/cjs/Circle.d.ts
CHANGED
|
@@ -12,13 +12,16 @@
|
|
|
12
12
|
* @modified 2022-08-15 Added the `containsPoint` function.
|
|
13
13
|
* @modified 2022-08-23 Added the `lineIntersection` function.
|
|
14
14
|
* @modified 2022-08-23 Added the `closestPoint` function.
|
|
15
|
-
* @
|
|
15
|
+
* @modified 2025-04-09 Added the `Circle.move(amount: XYCoords)` method.
|
|
16
|
+
* @modified 2025-04-16 Class `Circle` now implements interface `Intersectable`.
|
|
17
|
+
* @version 1.5.0
|
|
16
18
|
**/
|
|
19
|
+
import { Bounds } from "./Bounds";
|
|
17
20
|
import { Line } from "./Line";
|
|
18
21
|
import { Vector } from "./Vector";
|
|
19
22
|
import { VertTuple } from "./VertTuple";
|
|
20
23
|
import { Vertex } from "./Vertex";
|
|
21
|
-
import { SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
24
|
+
import { IBounded, Intersectable, SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
22
25
|
/**
|
|
23
26
|
* @classdesc A simple circle: center point and radius.
|
|
24
27
|
*
|
|
@@ -30,7 +33,7 @@ import { SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
|
30
33
|
* @requires UID
|
|
31
34
|
* @requires UIDGenerator
|
|
32
35
|
**/
|
|
33
|
-
export declare class Circle implements SVGSerializable {
|
|
36
|
+
export declare class Circle implements IBounded, Intersectable, SVGSerializable {
|
|
34
37
|
/**
|
|
35
38
|
* Required to generate proper CSS classes and other class related IDs.
|
|
36
39
|
**/
|
|
@@ -72,6 +75,16 @@ export declare class Circle implements SVGSerializable {
|
|
|
72
75
|
* @param {number} radius - The radius of the circle.
|
|
73
76
|
*/
|
|
74
77
|
constructor(center: Vertex, radius: number);
|
|
78
|
+
/**
|
|
79
|
+
* Move the circle by the given amount.
|
|
80
|
+
*
|
|
81
|
+
* @method move
|
|
82
|
+
* @param {XYCoords} amount - The amount to move.
|
|
83
|
+
* @instance
|
|
84
|
+
* @memberof Circle
|
|
85
|
+
* @return {Circle} this for chaining
|
|
86
|
+
**/
|
|
87
|
+
move(amount: XYCoords): Circle;
|
|
75
88
|
/**
|
|
76
89
|
* Check if the given circle is fully contained inside this circle.
|
|
77
90
|
*
|
|
@@ -129,6 +142,15 @@ export declare class Circle implements SVGSerializable {
|
|
|
129
142
|
* @memberof Circle
|
|
130
143
|
**/
|
|
131
144
|
tangentAt(angle: number): Vector;
|
|
145
|
+
/**
|
|
146
|
+
* Get the bounding box (bounds) of this Circle.
|
|
147
|
+
*
|
|
148
|
+
* @method getBounds
|
|
149
|
+
* @instance
|
|
150
|
+
* @memberof Circle
|
|
151
|
+
* @return {Bounds} The rectangular bounds of this Circle.
|
|
152
|
+
**/
|
|
153
|
+
getBounds(): Bounds;
|
|
132
154
|
/**
|
|
133
155
|
* Calculate the intersection points (if exists) with the given circle.
|
|
134
156
|
*
|
|
@@ -146,10 +168,30 @@ export declare class Circle implements SVGSerializable {
|
|
|
146
168
|
* @instance
|
|
147
169
|
* @memberof Circle
|
|
148
170
|
* @param {Vertex} a- The first of the two points defining the line.
|
|
149
|
-
* @param {
|
|
171
|
+
* @param {XYCoords} b - The second of the two points defining the line.
|
|
150
172
|
* @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
|
|
151
173
|
**/
|
|
152
174
|
lineIntersection(a: Vertex, b: XYCoords): Line | null;
|
|
175
|
+
/**
|
|
176
|
+
* Get all line intersections with this circle.
|
|
177
|
+
*
|
|
178
|
+
* This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
|
|
179
|
+
*
|
|
180
|
+
* @param {VertTuple} line - The line to find intersections with.
|
|
181
|
+
* @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
|
|
182
|
+
* @returns {Array<Vertex>} - An array of all intersections with the circle outline.
|
|
183
|
+
*/
|
|
184
|
+
lineIntersections(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vertex>;
|
|
185
|
+
/**
|
|
186
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
187
|
+
*
|
|
188
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
189
|
+
*
|
|
190
|
+
* @param line
|
|
191
|
+
* @param lineIntersectionTangents
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
lineIntersectionTangents(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vector>;
|
|
153
195
|
/**
|
|
154
196
|
* Calculate the closest point on the outline of this circle to the given point.
|
|
155
197
|
*
|
package/src/cjs/Circle.js
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
* @modified 2022-08-15 Added the `containsPoint` function.
|
|
14
14
|
* @modified 2022-08-23 Added the `lineIntersection` function.
|
|
15
15
|
* @modified 2022-08-23 Added the `closestPoint` function.
|
|
16
|
-
* @
|
|
16
|
+
* @modified 2025-04-09 Added the `Circle.move(amount: XYCoords)` method.
|
|
17
|
+
* @modified 2025-04-16 Class `Circle` now implements interface `Intersectable`.
|
|
18
|
+
* @version 1.5.0
|
|
17
19
|
**/
|
|
18
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
21
|
exports.Circle = void 0;
|
|
22
|
+
var Bounds_1 = require("./Bounds");
|
|
20
23
|
var Line_1 = require("./Line");
|
|
21
24
|
var UIDGenerator_1 = require("./UIDGenerator");
|
|
22
25
|
var Vector_1 = require("./Vector");
|
|
@@ -50,6 +53,19 @@ var Circle = /** @class */ (function () {
|
|
|
50
53
|
this.center = center;
|
|
51
54
|
this.radius = radius;
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Move the circle by the given amount.
|
|
58
|
+
*
|
|
59
|
+
* @method move
|
|
60
|
+
* @param {XYCoords} amount - The amount to move.
|
|
61
|
+
* @instance
|
|
62
|
+
* @memberof Circle
|
|
63
|
+
* @return {Circle} this for chaining
|
|
64
|
+
**/
|
|
65
|
+
Circle.prototype.move = function (amount) {
|
|
66
|
+
this.center.add(amount);
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
53
69
|
/**
|
|
54
70
|
* Check if the given circle is fully contained inside this circle.
|
|
55
71
|
*
|
|
@@ -120,7 +136,21 @@ var Circle = /** @class */ (function () {
|
|
|
120
136
|
var pointA = Circle.circleUtils.vertAt(angle, this.radius);
|
|
121
137
|
// Construct the perpendicular of the line in point a. Then move relative to center.
|
|
122
138
|
return new Vector_1.Vector(pointA, new Vertex_1.Vertex(0, 0)).add(this.center).perp();
|
|
139
|
+
// return (new Vector(this.center.clone(), pointA).add(pointA) as Vector).perp() as Vector;
|
|
123
140
|
};
|
|
141
|
+
//--- BEGIN --- Implement interface `Intersectable`
|
|
142
|
+
/**
|
|
143
|
+
* Get the bounding box (bounds) of this Circle.
|
|
144
|
+
*
|
|
145
|
+
* @method getBounds
|
|
146
|
+
* @instance
|
|
147
|
+
* @memberof Circle
|
|
148
|
+
* @return {Bounds} The rectangular bounds of this Circle.
|
|
149
|
+
**/
|
|
150
|
+
Circle.prototype.getBounds = function () {
|
|
151
|
+
return new Bounds_1.Bounds(this.center.clone().subXY(Math.abs(this.radius), Math.abs(this.radius)), this.center.clone().addXY(Math.abs(this.radius), Math.abs(this.radius)));
|
|
152
|
+
};
|
|
153
|
+
//--- END --- Implement interface `Intersectable`
|
|
124
154
|
/**
|
|
125
155
|
* Calculate the intersection points (if exists) with the given circle.
|
|
126
156
|
*
|
|
@@ -180,7 +210,7 @@ var Circle = /** @class */ (function () {
|
|
|
180
210
|
* @instance
|
|
181
211
|
* @memberof Circle
|
|
182
212
|
* @param {Vertex} a- The first of the two points defining the line.
|
|
183
|
-
* @param {
|
|
213
|
+
* @param {XYCoords} b - The second of the two points defining the line.
|
|
184
214
|
* @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
|
|
185
215
|
**/
|
|
186
216
|
Circle.prototype.lineIntersection = function (a, b) {
|
|
@@ -213,8 +243,57 @@ var Circle = /** @class */ (function () {
|
|
|
213
243
|
interA.y = (-det * diff.x + Math.abs(diff.y) * sqrt) / distSquared;
|
|
214
244
|
interB.y = (-det * diff.x - Math.abs(diff.y) * sqrt) / distSquared;
|
|
215
245
|
return new Line_1.Line(interA.add(this.center), interB.add(this.center));
|
|
216
|
-
// return new Line(interA, interB);
|
|
217
246
|
};
|
|
247
|
+
//--- BEGIN --- Implement interface `Intersectable`
|
|
248
|
+
/**
|
|
249
|
+
* Get all line intersections with this circle.
|
|
250
|
+
*
|
|
251
|
+
* This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
|
|
252
|
+
*
|
|
253
|
+
* @param {VertTuple} line - The line to find intersections with.
|
|
254
|
+
* @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
|
|
255
|
+
* @returns {Array<Vertex>} - An array of all intersections with the circle outline.
|
|
256
|
+
*/
|
|
257
|
+
Circle.prototype.lineIntersections = function (line, inVectorBoundsOnly) {
|
|
258
|
+
if (inVectorBoundsOnly === void 0) { inVectorBoundsOnly = false; }
|
|
259
|
+
// Find the intersections of all lines inside the edge bounds
|
|
260
|
+
var intersectioLine = this.lineIntersection(line.a, line.b);
|
|
261
|
+
if (!intersectioLine) {
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
264
|
+
if (inVectorBoundsOnly) {
|
|
265
|
+
// const maxDist = line.length();
|
|
266
|
+
return [intersectioLine.a, intersectioLine.b].filter(function (vert) { return line.hasPoint(vert, true); });
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
return [intersectioLine.a, intersectioLine.b];
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
274
|
+
*
|
|
275
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
276
|
+
*
|
|
277
|
+
* @param line
|
|
278
|
+
* @param lineIntersectionTangents
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
281
|
+
Circle.prototype.lineIntersectionTangents = function (line, inVectorBoundsOnly) {
|
|
282
|
+
var _this = this;
|
|
283
|
+
if (inVectorBoundsOnly === void 0) { inVectorBoundsOnly = false; }
|
|
284
|
+
// Find the intersections of all lines plus their tangents inside the circle bounds
|
|
285
|
+
var interSectionPoints = this.lineIntersections(line, inVectorBoundsOnly);
|
|
286
|
+
return interSectionPoints.map(function (vert) {
|
|
287
|
+
// Calculate angle
|
|
288
|
+
var lineFromCenter = new Line_1.Line(_this.center, vert);
|
|
289
|
+
var angle = lineFromCenter.angle();
|
|
290
|
+
// console.log("angle", (angle / Math.PI) * 180.0);
|
|
291
|
+
// const angle = Math.random() * Math.PI * 2; // TODO
|
|
292
|
+
// Calculate tangent at angle
|
|
293
|
+
return _this.tangentAt(angle);
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
//--- END --- Implement interface `Intersectable`
|
|
218
297
|
/**
|
|
219
298
|
* Calculate the closest point on the outline of this circle to the given point.
|
|
220
299
|
*
|
package/src/cjs/Circle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../ts/Circle.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../ts/Circle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;IAiBI;;;AAEJ,mCAAkC;AAClC,+BAA8B;AAC9B,+CAA8C;AAC9C,mCAAkC;AAElC,mCAAkC;AAGlC;;;;;;;;;;IAUI;AACJ;IAsCE;;;;;;;OAOG;IACH,gBAAY,MAAc,EAAE,MAAc;QA7C1C;;YAEI;QACK,cAAS,GAAW,QAAQ,CAAC;QA2CpC,IAAI,CAAC,G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IAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,8FAA8F;YAC9F,OAAO,IAAI,eAAM,EAAE,CAAC;QACtB,CAAC;QACD,wBAAwB;QACxB,IAAI,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1E,OAAO,gBAAgB,CAAC,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,OAAO,gBAAgB,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAEM,kBAAW,GAAG;QACnB,MAAM,EAAE,UAAC,KAAa,EAAE,MAAc;YACpC;uDACkC;YAClC,OAAO,IAAI,eAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC;QACxE,CAAC;KACF,AANiB,CAMhB;IACJ,aAAC;CAAA,AA/VD,IA+VC,CAAC,YAAY;AA/VD,wBAAM"}
|
|
@@ -8,11 +8,18 @@
|
|
|
8
8
|
* @modified 2024-03-08 Added the `containsAngle` method.
|
|
9
9
|
* @modified 2024-03-09 Added the `circleSectorIntersection` method to find coherent sector intersections..
|
|
10
10
|
* @modified 2024-03-09 Added the `angleAt` method to determine any angle at some ratio.
|
|
11
|
+
* @modified 2025-04-02 Adding the `CircleSector.lineIntersections` and `CircleSector.lineIntersectionTangents` and implementing `Intersectable`.
|
|
12
|
+
* @modified 2025-04-09 Adding the `CircleSector.move()` method.
|
|
13
|
+
* @modified 2025-04-19 Tweaking the `CircleSector.containsAngle` method: all values (input angle, start- and end- angle) are wrapped into [0,2*PI) now.
|
|
14
|
+
* @modified 2025-04-19 Class `CircleSector` implements interface `Bounded` now (method `getBounds` added).
|
|
11
15
|
* @version 1.2.0
|
|
12
16
|
**/
|
|
17
|
+
import { Bounds } from "./Bounds";
|
|
13
18
|
import { Circle } from "./Circle";
|
|
19
|
+
import { Vector } from "./Vector";
|
|
20
|
+
import { VertTuple } from "./VertTuple";
|
|
14
21
|
import { Vertex } from "./Vertex";
|
|
15
|
-
import { SVGPathParams, SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
22
|
+
import { IBounded, Intersectable, SVGPathParams, SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
16
23
|
/**
|
|
17
24
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
18
25
|
*
|
|
@@ -22,7 +29,7 @@ import { SVGPathParams, SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
|
22
29
|
* @requires UIDGenerator
|
|
23
30
|
* @requires XYCoords
|
|
24
31
|
**/
|
|
25
|
-
export declare class CircleSector implements SVGSerializable {
|
|
32
|
+
export declare class CircleSector implements IBounded, Intersectable, SVGSerializable {
|
|
26
33
|
/**
|
|
27
34
|
* Required to generate proper CSS classes and other class related IDs.
|
|
28
35
|
**/
|
|
@@ -71,6 +78,28 @@ export declare class CircleSector implements SVGSerializable {
|
|
|
71
78
|
* @param {number} endAngle - The end angle of the sector.
|
|
72
79
|
*/
|
|
73
80
|
constructor(circle: Circle, startAngle: number, endAngle: number);
|
|
81
|
+
/**
|
|
82
|
+
* Get the bounds of this ellipse.
|
|
83
|
+
*
|
|
84
|
+
* The bounds are approximated by the underlying segment buffer; the more segment there are,
|
|
85
|
+
* the more accurate will be the returned bounds.
|
|
86
|
+
*
|
|
87
|
+
* @method getBounds
|
|
88
|
+
* @instance
|
|
89
|
+
* @memberof VEllipse
|
|
90
|
+
* @return {Bounds} The bounds of this curve.
|
|
91
|
+
**/
|
|
92
|
+
getBounds(): Bounds;
|
|
93
|
+
/**
|
|
94
|
+
* Move the circle sector by the given amount.
|
|
95
|
+
*
|
|
96
|
+
* @method move
|
|
97
|
+
* @param {XYCoords} amount - The amount to move.
|
|
98
|
+
* @instance
|
|
99
|
+
* @memberof CircleSector
|
|
100
|
+
* @return {CircleSector} this for chaining
|
|
101
|
+
**/
|
|
102
|
+
move(amount: XYCoords): CircleSector;
|
|
74
103
|
/**
|
|
75
104
|
* Checks wether the given angle (must be inside 0 and PI*2) is contained inside this sector.
|
|
76
105
|
*
|
|
@@ -123,6 +152,26 @@ export declare class CircleSector implements SVGSerializable {
|
|
|
123
152
|
* @return {CircleSector | null} The intersecion of both sectors or null if they don't intersect.
|
|
124
153
|
*/
|
|
125
154
|
circleSectorIntersection(sector: CircleSector): CircleSector | null;
|
|
155
|
+
/**
|
|
156
|
+
* Get the line intersections as vectors with this ellipse.
|
|
157
|
+
*
|
|
158
|
+
* @method lineIntersections
|
|
159
|
+
* @instance
|
|
160
|
+
* @param {VertTuple<Vector> ray - The line/ray to intersect this ellipse with.
|
|
161
|
+
* @param {boolean} inVectorBoundsOnly - (default=false) Set to true if only intersections within the vector bounds are of interest.
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
lineIntersections(ray: VertTuple<Vector>, inVectorBoundsOnly?: boolean): Array<Vertex>;
|
|
165
|
+
/**
|
|
166
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
167
|
+
*
|
|
168
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
169
|
+
*
|
|
170
|
+
* @param line
|
|
171
|
+
* @param lineIntersectionTangents
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
lineIntersectionTangents(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vector>;
|
|
126
175
|
/**
|
|
127
176
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
128
177
|
* After calling this function the object might not hold valid data any more and
|
package/src/cjs/CircleSector.js
CHANGED
|
@@ -9,12 +9,20 @@
|
|
|
9
9
|
* @modified 2024-03-08 Added the `containsAngle` method.
|
|
10
10
|
* @modified 2024-03-09 Added the `circleSectorIntersection` method to find coherent sector intersections..
|
|
11
11
|
* @modified 2024-03-09 Added the `angleAt` method to determine any angle at some ratio.
|
|
12
|
+
* @modified 2025-04-02 Adding the `CircleSector.lineIntersections` and `CircleSector.lineIntersectionTangents` and implementing `Intersectable`.
|
|
13
|
+
* @modified 2025-04-09 Adding the `CircleSector.move()` method.
|
|
14
|
+
* @modified 2025-04-19 Tweaking the `CircleSector.containsAngle` method: all values (input angle, start- and end- angle) are wrapped into [0,2*PI) now.
|
|
15
|
+
* @modified 2025-04-19 Class `CircleSector` implements interface `Bounded` now (method `getBounds` added).
|
|
12
16
|
* @version 1.2.0
|
|
13
17
|
**/
|
|
14
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
19
|
exports.CircleSector = void 0;
|
|
20
|
+
var Bounds_1 = require("./Bounds");
|
|
16
21
|
var Circle_1 = require("./Circle");
|
|
22
|
+
var Line_1 = require("./Line");
|
|
17
23
|
var UIDGenerator_1 = require("./UIDGenerator");
|
|
24
|
+
var Vertex_1 = require("./Vertex");
|
|
25
|
+
var geomutils_1 = require("./geomutils");
|
|
18
26
|
/**
|
|
19
27
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
20
28
|
*
|
|
@@ -44,6 +52,49 @@ var CircleSector = /** @class */ (function () {
|
|
|
44
52
|
this.startAngle = startAngle;
|
|
45
53
|
this.endAngle = endAngle;
|
|
46
54
|
}
|
|
55
|
+
//--- BEGIN --- Implement interface `IBounded`
|
|
56
|
+
/**
|
|
57
|
+
* Get the bounds of this ellipse.
|
|
58
|
+
*
|
|
59
|
+
* The bounds are approximated by the underlying segment buffer; the more segment there are,
|
|
60
|
+
* the more accurate will be the returned bounds.
|
|
61
|
+
*
|
|
62
|
+
* @method getBounds
|
|
63
|
+
* @instance
|
|
64
|
+
* @memberof VEllipse
|
|
65
|
+
* @return {Bounds} The bounds of this curve.
|
|
66
|
+
**/
|
|
67
|
+
CircleSector.prototype.getBounds = function () {
|
|
68
|
+
var _self = this;
|
|
69
|
+
var circleBounds = this.circle.getBounds();
|
|
70
|
+
// Calculage angles from east, west, north and south box points and check if they are inside
|
|
71
|
+
var candidates = [
|
|
72
|
+
circleBounds.getNorthPoint(),
|
|
73
|
+
circleBounds.getSouthPoint(),
|
|
74
|
+
circleBounds.getWestPoint(),
|
|
75
|
+
circleBounds.getEastPoint()
|
|
76
|
+
].filter(function (point) {
|
|
77
|
+
// Check for each candidate points if they are contained in this sector. Drop if not.
|
|
78
|
+
var angle = new Line_1.Line(_self.circle.center, point).angle();
|
|
79
|
+
return _self.containsAngle(angle);
|
|
80
|
+
});
|
|
81
|
+
// Compute bounds and inlcude start end end point (they are definitely part of the bounds)
|
|
82
|
+
return Bounds_1.Bounds.computeFromVertices(candidates.concat([this.getStartPoint(), this.getEndPoint()]));
|
|
83
|
+
};
|
|
84
|
+
//--- BEGIN --- Implement interface `IBounded`
|
|
85
|
+
/**
|
|
86
|
+
* Move the circle sector by the given amount.
|
|
87
|
+
*
|
|
88
|
+
* @method move
|
|
89
|
+
* @param {XYCoords} amount - The amount to move.
|
|
90
|
+
* @instance
|
|
91
|
+
* @memberof CircleSector
|
|
92
|
+
* @return {CircleSector} this for chaining
|
|
93
|
+
**/
|
|
94
|
+
CircleSector.prototype.move = function (amount) {
|
|
95
|
+
this.circle.move(amount);
|
|
96
|
+
return this;
|
|
97
|
+
};
|
|
47
98
|
/**
|
|
48
99
|
* Checks wether the given angle (must be inside 0 and PI*2) is contained inside this sector.
|
|
49
100
|
*
|
|
@@ -54,12 +105,22 @@ var CircleSector = /** @class */ (function () {
|
|
|
54
105
|
* @return {boolean} True if (and only if) this sector contains the given angle.
|
|
55
106
|
*/
|
|
56
107
|
CircleSector.prototype.containsAngle = function (angle) {
|
|
57
|
-
|
|
58
|
-
|
|
108
|
+
var wrappedAngle = geomutils_1.geomutils.mapAngleTo2PI(angle);
|
|
109
|
+
var wrappedStart = geomutils_1.geomutils.mapAngleTo2PI(this.startAngle);
|
|
110
|
+
var wrappedEnd = geomutils_1.geomutils.mapAngleTo2PI(this.endAngle);
|
|
111
|
+
// TODO: cleanup
|
|
112
|
+
// if (this.startAngle <= this.endAngle) {
|
|
113
|
+
// return angle >= this.startAngle && angle < this.endAngle;
|
|
114
|
+
// } else {
|
|
115
|
+
// // startAngle > endAngle
|
|
116
|
+
// return angle >= this.startAngle || angle < this.endAngle;
|
|
117
|
+
// }
|
|
118
|
+
if (wrappedStart <= wrappedEnd) {
|
|
119
|
+
return wrappedAngle >= wrappedStart && wrappedAngle < wrappedEnd;
|
|
59
120
|
}
|
|
60
121
|
else {
|
|
61
122
|
// startAngle > endAngle
|
|
62
|
-
return
|
|
123
|
+
return wrappedAngle >= wrappedStart || wrappedAngle < wrappedEnd;
|
|
63
124
|
}
|
|
64
125
|
};
|
|
65
126
|
/**
|
|
@@ -153,6 +214,54 @@ var CircleSector = /** @class */ (function () {
|
|
|
153
214
|
}
|
|
154
215
|
return resultSector;
|
|
155
216
|
};
|
|
217
|
+
//--- BEGIN --- Implement interface `Intersectable`
|
|
218
|
+
/**
|
|
219
|
+
* Get the line intersections as vectors with this ellipse.
|
|
220
|
+
*
|
|
221
|
+
* @method lineIntersections
|
|
222
|
+
* @instance
|
|
223
|
+
* @param {VertTuple<Vector> ray - The line/ray to intersect this ellipse with.
|
|
224
|
+
* @param {boolean} inVectorBoundsOnly - (default=false) Set to true if only intersections within the vector bounds are of interest.
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
CircleSector.prototype.lineIntersections = function (ray, inVectorBoundsOnly) {
|
|
228
|
+
var _this = this;
|
|
229
|
+
if (inVectorBoundsOnly === void 0) { inVectorBoundsOnly = false; }
|
|
230
|
+
// First get all line intersections from underlying ellipse.
|
|
231
|
+
var ellipseIntersections = this.circle.lineIntersections(ray, inVectorBoundsOnly);
|
|
232
|
+
// Drop all intersection points that are not contained in the circle sectors bounds.
|
|
233
|
+
var tmpLine = new Line_1.Line(this.circle.center, new Vertex_1.Vertex());
|
|
234
|
+
return ellipseIntersections.filter(function (intersectionPoint) {
|
|
235
|
+
tmpLine.b.set(intersectionPoint);
|
|
236
|
+
var lineAngle = tmpLine.angle();
|
|
237
|
+
return _this.containsAngle(geomutils_1.geomutils.wrapMinMax(lineAngle, 0, Math.PI * 2));
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
242
|
+
*
|
|
243
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
244
|
+
*
|
|
245
|
+
* @param line
|
|
246
|
+
* @param lineIntersectionTangents
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
249
|
+
CircleSector.prototype.lineIntersectionTangents = function (line, inVectorBoundsOnly) {
|
|
250
|
+
var _this = this;
|
|
251
|
+
if (inVectorBoundsOnly === void 0) { inVectorBoundsOnly = false; }
|
|
252
|
+
// Find the intersections of all lines plus their tangents inside the circle bounds
|
|
253
|
+
var interSectionPoints = this.lineIntersections(line, inVectorBoundsOnly);
|
|
254
|
+
return interSectionPoints.map(function (vert) {
|
|
255
|
+
// Calculate angle
|
|
256
|
+
var lineFromCenter = new Line_1.Line(_this.circle.center, vert);
|
|
257
|
+
var angle = lineFromCenter.angle();
|
|
258
|
+
// console.log("angle", (angle / Math.PI) * 180.0);
|
|
259
|
+
// const angle = Math.random() * Math.PI * 2; // TODO
|
|
260
|
+
// Calculate tangent at angle
|
|
261
|
+
return _this.circle.tangentAt(angle);
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
//--- END --- Implement interface `Intersectable`
|
|
156
265
|
/**
|
|
157
266
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
158
267
|
* After calling this function the object might not hold valid data any more and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircleSector.js","sourceRoot":"","sources":["../ts/CircleSector.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"CircleSector.js","sourceRoot":"","sources":["../ts/CircleSector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;IAeI;;;AAEJ,mCAAkC;AAClC,mCAAkC;AAClC,+BAA8B;AAC9B,+CAA8C;AAG9C,mCAAkC;AAClC,yCAAwC;AAGxC;;;;;;;;IAQI;AACJ;IA6CE;;;;;;;;OAQG;IACH,sBAAY,MAAc,EAAE,UAAkB,EAAE,QAAgB;QArDhE;;YAEI;QACK,cAAS,GAAW,cAAc,CAAC;QAmD1C,IAAI,CAAC,GAAG,GAAG,2BAAY,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,8CAA8C;IAC9C;;;;;;;;;;QAUI;IACJ,gCAAS,GAAT;QACE,IAAM,KAAK,GAAG,IAAI,CAAC;QACnB,IAAM,YAAY,GAAY,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtD,4FAA4F;QAC5F,IAAM,UAAU,GAAmB;YACjC,YAAY,CAAC,aAAa,EAAE;YAC5B,YAAY,CAAC,aAAa,EAAE;YAC5B,YAAY,CAAC,YAAY,EAAE;YAC3B,YAAY,CAAC,YAAY,EAAE;SAC5B,CAAC,MAAM,CAAE,UAAC,KAAc;YACvB,qFAAqF;YACrF,IAAM,KAAK,GAAY,IAAI,WAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;YACpE,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,0FAA0F;QAC1F,OAAO,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