plotboilerplate 1.23.2 → 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 +8351 -6928
- 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 +1590 -123
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +4 -2
- 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.d.ts +4 -2
- package/src/cjs/PlotBoilerplate.js +9 -12
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +153 -6
- package/src/cjs/Polygon.js +304 -23
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.d.ts +73 -4
- package/src/cjs/Triangle.js +94 -2
- 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 +39 -10
- package/src/cjs/VertTuple.js +49 -11
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +18 -2
- package/src/cjs/Vertex.js +22 -2
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/draw.d.ts +1 -0
- package/src/cjs/draw.js +2 -1
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawutilssvg.js +24 -0
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/geomutils.d.ts +32 -1
- package/src/cjs/geomutils.js +47 -1
- package/src/cjs/geomutils.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/PolygonInset.d.ts +184 -0
- package/src/cjs/utils/algorithms/PolygonInset.js +431 -0
- package/src/cjs/utils/algorithms/PolygonInset.js.map +1 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js +6 -3
- package/src/cjs/utils/algorithms/clearDuplicateVertices.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/algorithms/findPolygonSelfIntersections.d.ts +2 -1
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js +3 -3
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.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/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/guiSizeToggler.d.ts +2 -1
- package/src/cjs/utils/dom/guiSizeToggler.js +5 -3
- package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
- 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.d.ts +4 -2
- package/src/esm/PlotBoilerplate.js +9 -12
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +153 -6
- package/src/esm/Polygon.js +301 -23
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.d.ts +73 -4
- package/src/esm/Triangle.js +91 -2
- 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 +39 -10
- package/src/esm/VertTuple.js +49 -11
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +18 -2
- package/src/esm/Vertex.js +22 -2
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/draw.d.ts +1 -0
- package/src/esm/draw.js +2 -1
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawutilssvg.js +24 -0
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/geomutils.d.ts +32 -1
- package/src/esm/geomutils.js +47 -1
- package/src/esm/geomutils.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/PolygonInset.d.ts +184 -0
- package/src/esm/utils/algorithms/PolygonInset.js +424 -0
- package/src/esm/utils/algorithms/PolygonInset.js.map +1 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
- package/src/esm/utils/algorithms/clearDuplicateVertices.js +6 -3
- package/src/esm/utils/algorithms/clearDuplicateVertices.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/algorithms/findPolygonSelfIntersections.d.ts +2 -1
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js +3 -3
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- 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/detectDarkMode.js.map +1 -1
- package/src/esm/utils/dom/guiSizeToggler.d.ts +2 -1
- package/src/esm/utils/dom/guiSizeToggler.js +4 -2
- package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
- 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 +10 -12
- package/src/ts/Polygon.ts +329 -27
- package/src/ts/Triangle.ts +101 -5
- 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 +53 -13
- package/src/ts/Vertex.ts +24 -3
- package/src/ts/draw.ts +2 -1
- package/src/ts/drawutilssvg.ts +29 -0
- package/src/ts/geomutils.ts +49 -1
- package/src/ts/interfaces/core.ts +42 -0
- package/src/ts/utils/algorithms/PolygonInset.ts +529 -0
- package/src/ts/utils/algorithms/clearDuplicateVertices.ts +11 -8
- package/src/ts/utils/algorithms/convexPolygonIncircle.ts +82 -78
- package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts +25 -26
- package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts +92 -99
- package/src/ts/utils/createRandomizedPolygon.ts +31 -0
- package/src/ts/utils/detectDarkMode.ts +1 -3
- package/src/ts/utils/dom/guiSizeToggler.ts +4 -2
- 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
|
@@ -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/esm/CircleSector.js
CHANGED
|
@@ -8,10 +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 { Line } from "./Line";
|
|
14
20
|
import { UIDGenerator } from "./UIDGenerator";
|
|
21
|
+
import { Vertex } from "./Vertex";
|
|
22
|
+
import { geomutils } from "./geomutils";
|
|
15
23
|
/**
|
|
16
24
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
17
25
|
*
|
|
@@ -41,6 +49,49 @@ export class CircleSector {
|
|
|
41
49
|
this.startAngle = startAngle;
|
|
42
50
|
this.endAngle = endAngle;
|
|
43
51
|
}
|
|
52
|
+
//--- BEGIN --- Implement interface `IBounded`
|
|
53
|
+
/**
|
|
54
|
+
* Get the bounds of this ellipse.
|
|
55
|
+
*
|
|
56
|
+
* The bounds are approximated by the underlying segment buffer; the more segment there are,
|
|
57
|
+
* the more accurate will be the returned bounds.
|
|
58
|
+
*
|
|
59
|
+
* @method getBounds
|
|
60
|
+
* @instance
|
|
61
|
+
* @memberof VEllipse
|
|
62
|
+
* @return {Bounds} The bounds of this curve.
|
|
63
|
+
**/
|
|
64
|
+
getBounds() {
|
|
65
|
+
const _self = this;
|
|
66
|
+
const circleBounds = this.circle.getBounds();
|
|
67
|
+
// Calculage angles from east, west, north and south box points and check if they are inside
|
|
68
|
+
const candidates = [
|
|
69
|
+
circleBounds.getNorthPoint(),
|
|
70
|
+
circleBounds.getSouthPoint(),
|
|
71
|
+
circleBounds.getWestPoint(),
|
|
72
|
+
circleBounds.getEastPoint()
|
|
73
|
+
].filter((point) => {
|
|
74
|
+
// Check for each candidate points if they are contained in this sector. Drop if not.
|
|
75
|
+
const angle = new Line(_self.circle.center, point).angle();
|
|
76
|
+
return _self.containsAngle(angle);
|
|
77
|
+
});
|
|
78
|
+
// Compute bounds and inlcude start end end point (they are definitely part of the bounds)
|
|
79
|
+
return Bounds.computeFromVertices(candidates.concat([this.getStartPoint(), this.getEndPoint()]));
|
|
80
|
+
}
|
|
81
|
+
//--- BEGIN --- Implement interface `IBounded`
|
|
82
|
+
/**
|
|
83
|
+
* Move the circle sector by the given amount.
|
|
84
|
+
*
|
|
85
|
+
* @method move
|
|
86
|
+
* @param {XYCoords} amount - The amount to move.
|
|
87
|
+
* @instance
|
|
88
|
+
* @memberof CircleSector
|
|
89
|
+
* @return {CircleSector} this for chaining
|
|
90
|
+
**/
|
|
91
|
+
move(amount) {
|
|
92
|
+
this.circle.move(amount);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
44
95
|
/**
|
|
45
96
|
* Checks wether the given angle (must be inside 0 and PI*2) is contained inside this sector.
|
|
46
97
|
*
|
|
@@ -51,12 +102,22 @@ export class CircleSector {
|
|
|
51
102
|
* @return {boolean} True if (and only if) this sector contains the given angle.
|
|
52
103
|
*/
|
|
53
104
|
containsAngle(angle) {
|
|
54
|
-
|
|
55
|
-
|
|
105
|
+
var wrappedAngle = geomutils.mapAngleTo2PI(angle);
|
|
106
|
+
var wrappedStart = geomutils.mapAngleTo2PI(this.startAngle);
|
|
107
|
+
var wrappedEnd = geomutils.mapAngleTo2PI(this.endAngle);
|
|
108
|
+
// TODO: cleanup
|
|
109
|
+
// if (this.startAngle <= this.endAngle) {
|
|
110
|
+
// return angle >= this.startAngle && angle < this.endAngle;
|
|
111
|
+
// } else {
|
|
112
|
+
// // startAngle > endAngle
|
|
113
|
+
// return angle >= this.startAngle || angle < this.endAngle;
|
|
114
|
+
// }
|
|
115
|
+
if (wrappedStart <= wrappedEnd) {
|
|
116
|
+
return wrappedAngle >= wrappedStart && wrappedAngle < wrappedEnd;
|
|
56
117
|
}
|
|
57
118
|
else {
|
|
58
119
|
// startAngle > endAngle
|
|
59
|
-
return
|
|
120
|
+
return wrappedAngle >= wrappedStart || wrappedAngle < wrappedEnd;
|
|
60
121
|
}
|
|
61
122
|
}
|
|
62
123
|
/**
|
|
@@ -150,6 +211,50 @@ export class CircleSector {
|
|
|
150
211
|
}
|
|
151
212
|
return resultSector;
|
|
152
213
|
}
|
|
214
|
+
//--- BEGIN --- Implement interface `Intersectable`
|
|
215
|
+
/**
|
|
216
|
+
* Get the line intersections as vectors with this ellipse.
|
|
217
|
+
*
|
|
218
|
+
* @method lineIntersections
|
|
219
|
+
* @instance
|
|
220
|
+
* @param {VertTuple<Vector> ray - The line/ray to intersect this ellipse with.
|
|
221
|
+
* @param {boolean} inVectorBoundsOnly - (default=false) Set to true if only intersections within the vector bounds are of interest.
|
|
222
|
+
* @returns
|
|
223
|
+
*/
|
|
224
|
+
lineIntersections(ray, inVectorBoundsOnly = false) {
|
|
225
|
+
// First get all line intersections from underlying ellipse.
|
|
226
|
+
const ellipseIntersections = this.circle.lineIntersections(ray, inVectorBoundsOnly);
|
|
227
|
+
// Drop all intersection points that are not contained in the circle sectors bounds.
|
|
228
|
+
const tmpLine = new Line(this.circle.center, new Vertex());
|
|
229
|
+
return ellipseIntersections.filter((intersectionPoint) => {
|
|
230
|
+
tmpLine.b.set(intersectionPoint);
|
|
231
|
+
const lineAngle = tmpLine.angle();
|
|
232
|
+
return this.containsAngle(geomutils.wrapMinMax(lineAngle, 0, Math.PI * 2));
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
237
|
+
*
|
|
238
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
239
|
+
*
|
|
240
|
+
* @param line
|
|
241
|
+
* @param lineIntersectionTangents
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
lineIntersectionTangents(line, inVectorBoundsOnly = false) {
|
|
245
|
+
// Find the intersections of all lines plus their tangents inside the circle bounds
|
|
246
|
+
const interSectionPoints = this.lineIntersections(line, inVectorBoundsOnly);
|
|
247
|
+
return interSectionPoints.map((vert) => {
|
|
248
|
+
// Calculate angle
|
|
249
|
+
const lineFromCenter = new Line(this.circle.center, vert);
|
|
250
|
+
const angle = lineFromCenter.angle();
|
|
251
|
+
// console.log("angle", (angle / Math.PI) * 180.0);
|
|
252
|
+
// const angle = Math.random() * Math.PI * 2; // TODO
|
|
253
|
+
// Calculate tangent at angle
|
|
254
|
+
return this.circle.tangentAt(angle);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
//--- END --- Implement interface `Intersectable`
|
|
153
258
|
/**
|
|
154
259
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
155
260
|
* 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,OAAO,EAAE,MA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QAED,oCAAoC;QACpC,MAAM,IAAI,GAAW,QAAQ,GAAG,UAAU,CAAC;QAC3C,IAAI,YAAoB,CAAC;QACzB,IAAI,SAAiB,CAAC;QACtB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YACb,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,SAAS,GAAG,CAAC,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,SAAS,GAAG,CAAC,CAAC;QAChB,CAAC;QAED,MAAM,QAAQ,GAAkB,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,AA9EuB,CA8EtB"}
|
|
@@ -23,14 +23,26 @@
|
|
|
23
23
|
* @modified 2022-10-17 The `CubicBezierCurve` class now implements the new `PathSegment` interface.
|
|
24
24
|
* @modified 2023-09-30 Added the function `CubicbezierCurve.getSubCurve(number,number)` – similar to `getSubCurveAt(...)` but with absolute position parameters.
|
|
25
25
|
* @modified 2023-10-07 Added the `trimEnd`, `trimEndAt`, `trimStart`, `trimStartAt` methods.
|
|
26
|
-
* @
|
|
26
|
+
* @modified 2025-04-09 Added the `CubicBezierCurve.move` method to match the convention – which just calls `translate`.
|
|
27
|
+
* @modified 2025-04-09 Modified the `CubicBezierCurve.translate` method: chaning parameter `Vertex` to more generalized `XYCoords`.
|
|
28
|
+
* @modified 2025-04-13 Changed visibility of `CubicBezierCurve.utils` from 'private' to 'public'.
|
|
29
|
+
* @modified 2025-04-13 Added helper function `CubicBezierCurve.utils.bezierCoeffs`.
|
|
30
|
+
* @modified 2025-04-13 Added helper functopn `CubicBezierCurve.utils.sgn(number)` for division safe sign calculation.
|
|
31
|
+
* @modified 2025-03-13 Class `CubicBezierCurve` is now implementing interface `Intersectable`.
|
|
32
|
+
* @modified 2025-04-18 Added evaluation method for cubic Bézier curves `CubicBezierCurve.utils.evaluateT`.
|
|
33
|
+
* @modified 2025-04-18 Refactored method `CubicBezierCurve.getPointAt` to use `evaluateT`.
|
|
34
|
+
* @modified 2025-04-18 Fixed the `CubicBezierCurve.getBounds` method: now returning the real bounding box. Before it was an approximated one.
|
|
35
|
+
* @modified 2025-ß4-18 Added helper methods for bounding box calculation `CubucBezierCurve.util.cubicPolyMinMax` and `cubicPoly`.
|
|
36
|
+
* @version 2.9.0
|
|
27
37
|
*
|
|
28
38
|
* @file CubicBezierCurve
|
|
29
39
|
* @public
|
|
30
40
|
**/
|
|
31
41
|
import { Bounds } from "./Bounds";
|
|
32
42
|
import { Vertex } from "./Vertex";
|
|
33
|
-
import {
|
|
43
|
+
import { Vector } from "./Vector";
|
|
44
|
+
import { XYCoords, UID, PathSegment, Intersectable, IBounded } from "./interfaces";
|
|
45
|
+
import { VertTuple } from "./VertTuple";
|
|
34
46
|
/**
|
|
35
47
|
* @classdesc A refactored cubic bezier curve class.
|
|
36
48
|
*
|
|
@@ -41,7 +53,7 @@ import { XYCoords, UID, PathSegment } from "./interfaces";
|
|
|
41
53
|
* @requires UID
|
|
42
54
|
* @requires UIDGenerator
|
|
43
55
|
*/
|
|
44
|
-
export declare class CubicBezierCurve implements PathSegment {
|
|
56
|
+
export declare class CubicBezierCurve implements IBounded, Intersectable, PathSegment {
|
|
45
57
|
/** @constant {number} */
|
|
46
58
|
static readonly START_POINT: number;
|
|
47
59
|
/** @constant {number} */
|
|
@@ -151,12 +163,22 @@ export declare class CubicBezierCurve implements PathSegment {
|
|
|
151
163
|
* Translate the whole curve by the given {x,y} amount: moves all four points.
|
|
152
164
|
*
|
|
153
165
|
* @method translate
|
|
154
|
-
* @param {
|
|
166
|
+
* @param {XYCoords} amount - The amount to translate this curve by.
|
|
155
167
|
* @instance
|
|
156
168
|
* @memberof CubicBezierCurve
|
|
157
169
|
* @return {CubicBezierCurve} this (for chaining).
|
|
158
170
|
**/
|
|
159
|
-
translate(amount:
|
|
171
|
+
translate(amount: XYCoords): CubicBezierCurve;
|
|
172
|
+
/**
|
|
173
|
+
* Translate the whole curve by the given {x,y} amount: moves all four points.
|
|
174
|
+
*
|
|
175
|
+
* @method translate
|
|
176
|
+
* @param {XYCoords} amount - The amount to translate this curve by.
|
|
177
|
+
* @instance
|
|
178
|
+
* @memberof CubicBezierCurve
|
|
179
|
+
* @return {CubicBezierCurve} this (for chaining).
|
|
180
|
+
**/
|
|
181
|
+
move(amount: XYCoords): CubicBezierCurve;
|
|
160
182
|
/**
|
|
161
183
|
* Reverse this curve, means swapping start- and end-point and swapping
|
|
162
184
|
* start-control- and end-control-point.
|
|
@@ -203,6 +225,9 @@ export declare class CubicBezierCurve implements PathSegment {
|
|
|
203
225
|
*
|
|
204
226
|
* This function uses a recursive approach by cutting the curve into several linear segments.
|
|
205
227
|
*
|
|
228
|
+
* @method getClosestT
|
|
229
|
+
* @instance
|
|
230
|
+
* @memberof CubicBezierCurve
|
|
206
231
|
* @param {Vertex} p - The point to find the closest position ('t' on the curve).
|
|
207
232
|
* @return {number}
|
|
208
233
|
**/
|
|
@@ -228,7 +253,10 @@ export declare class CubicBezierCurve implements PathSegment {
|
|
|
228
253
|
* The bounds are approximated by the underlying segment buffer; the more segment there are,
|
|
229
254
|
* the more accurate will be the returned bounds.
|
|
230
255
|
*
|
|
231
|
-
* @
|
|
256
|
+
* @method getClosestT
|
|
257
|
+
* @instance
|
|
258
|
+
* @memberof CubicBezierCurve
|
|
259
|
+
* @return {Bounds} The bounds of this ellipse.
|
|
232
260
|
**/
|
|
233
261
|
getBounds(): Bounds;
|
|
234
262
|
/**
|
|
@@ -470,6 +498,27 @@ export declare class CubicBezierCurve implements PathSegment {
|
|
|
470
498
|
* @return {Vertex} The end point of the ending point's tangent.
|
|
471
499
|
*/
|
|
472
500
|
getEndTangent(): Vertex;
|
|
501
|
+
/**
|
|
502
|
+
* Get all line intersections with this shape.
|
|
503
|
+
*
|
|
504
|
+
* This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
|
|
505
|
+
*
|
|
506
|
+
* @param {VertTuple} line - The line to find intersections with.
|
|
507
|
+
* @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
|
|
508
|
+
* @returns {Array<Vertex>} - An array of all intersections with the shape outline.
|
|
509
|
+
*/
|
|
510
|
+
lineIntersections(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vertex>;
|
|
511
|
+
/**
|
|
512
|
+
* Get all line intersections of this polygon and their tangents along the shape.
|
|
513
|
+
*
|
|
514
|
+
* This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
|
|
515
|
+
*
|
|
516
|
+
* @param line
|
|
517
|
+
* @param lineIntersectionTangents
|
|
518
|
+
* @returns
|
|
519
|
+
*/
|
|
520
|
+
lineIntersectionTangents(line: VertTuple<any>, inVectorBoundsOnly?: boolean): Array<Vector>;
|
|
521
|
+
lineIntersectionTs(line: VertTuple<any>): Array<number>;
|
|
473
522
|
/**
|
|
474
523
|
* Check if this and the specified curve are equal.<br>
|
|
475
524
|
* <br>
|
|
@@ -546,5 +595,62 @@ export declare class CubicBezierCurve implements PathSegment {
|
|
|
546
595
|
/**
|
|
547
596
|
* Helper utils.
|
|
548
597
|
*/
|
|
549
|
-
|
|
598
|
+
static utils: {
|
|
599
|
+
evaluateT: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
|
|
600
|
+
cubicPolyMinMax: (p0: number, p1: number, p2: number, p3: number) => {
|
|
601
|
+
min: number;
|
|
602
|
+
max: number;
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* Get the points of a sub curve at the given start end end offsets (values between 0.0 and 1.0).
|
|
606
|
+
*
|
|
607
|
+
* tStart >= tEnd is allowed, you will get a reversed sub curve then.
|
|
608
|
+
*
|
|
609
|
+
* @method getSubCurvePointsAt
|
|
610
|
+
* @param {CubicBezierCurve} curve – The curve to get the sub curve points from.
|
|
611
|
+
* @param {number} tStart – The start offset of the desired sub curve (must be in [0..1]).
|
|
612
|
+
* @param {number} tEnd – The end offset if the desired cub curve (must be in [0..1]).
|
|
613
|
+
* @instance
|
|
614
|
+
* @memberof CubicBezierCurve
|
|
615
|
+
* @return {CubicBezierCurve} The sub curve as a new curve.
|
|
616
|
+
**/
|
|
617
|
+
getSubCurvePointsAt: (curve: CubicBezierCurve, tStart: number, tEnd: number) => [Vertex, Vertex, Vertex, Vertex];
|
|
618
|
+
/**
|
|
619
|
+
* Compute the cubic roots for the given cubic polynomial coefficients.
|
|
620
|
+
*
|
|
621
|
+
* Based on
|
|
622
|
+
* http://mysite.verizon.net/res148h4j/javascript/script_exact_cubic.html#the%20source%20code
|
|
623
|
+
* Inspired by
|
|
624
|
+
* https://www.particleincell.com/2013/cubic-line-intersection/
|
|
625
|
+
* Thanks to Stephan Schmitt and Particle-In-Cell!
|
|
626
|
+
*
|
|
627
|
+
* @param poly
|
|
628
|
+
* @returns
|
|
629
|
+
*/
|
|
630
|
+
cubicRoots: (poly: number[]) => number[];
|
|
631
|
+
/**
|
|
632
|
+
* Compute the Bézier coefficients from the given Bézier point coordinates.
|
|
633
|
+
*
|
|
634
|
+
* @param {number} p0 - The start point coordinate.
|
|
635
|
+
* @param {number} p1 - The start control point coordinate.
|
|
636
|
+
* @param {number} p2 - The end control point coordinate.
|
|
637
|
+
* @param {number} p3 - The end point coordinate.
|
|
638
|
+
* @returns {[number,number,number,number]}
|
|
639
|
+
*/
|
|
640
|
+
bezierCoeffs: (p0: number, p1: number, p2: number, p3: number) => [number, number, number, number];
|
|
641
|
+
/**
|
|
642
|
+
* Calculate the cubic polynomial coefficients used to find the bounding box.
|
|
643
|
+
*
|
|
644
|
+
* @param {number} p0 - The start point coordinate.
|
|
645
|
+
* @param {number} p1 - The start control point coordinate.
|
|
646
|
+
* @param {number} p2 - The end control point coordinate.
|
|
647
|
+
* @param {number} p3 - The end point coordinate.
|
|
648
|
+
* @returns {[number,number,number]}
|
|
649
|
+
*/
|
|
650
|
+
cubicPoly: (p0: number, p1: number, p2: number, p3: number) => [number, number, number];
|
|
651
|
+
/**
|
|
652
|
+
* sign of number, but is division safe: no zero returned :)
|
|
653
|
+
*/
|
|
654
|
+
sgn(x: number): number;
|
|
655
|
+
};
|
|
550
656
|
}
|