plotboilerplate 1.22.0 → 1.23.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 +2 -0
- package/dist/index.esm.js +222 -76
- 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 +492 -337
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +5 -4
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Bounds.js +1 -1
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +64 -1
- package/src/cjs/CircleSector.js +121 -1
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/CubicBezierCurve.js +2 -2
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Grid.js.map +1 -1
- package/src/cjs/KeyHandler.d.ts +1 -1
- package/src/cjs/KeyHandler.js +13 -13
- package/src/cjs/KeyHandler.js.map +1 -1
- package/src/cjs/Line.js +2 -0
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/MouseHandler.d.ts +2 -2
- package/src/cjs/MouseHandler.js +7 -5
- package/src/cjs/MouseHandler.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +1 -1
- package/src/cjs/PlotBoilerplate.js +77 -63
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.js +1 -1
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/UIDGenerator.js +1 -1
- package/src/cjs/UIDGenerator.js.map +1 -1
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/VEllipseSector.js +1 -1
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vector.js +2 -0
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +3 -2
- package/src/cjs/Vertex.js +13 -7
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/VertexAttr.d.ts +2 -1
- package/src/cjs/VertexAttr.js +2 -1
- package/src/cjs/VertexAttr.js.map +1 -1
- package/src/cjs/VertexListeners.d.ts +1 -1
- package/src/cjs/VertexListeners.js.map +1 -1
- package/src/cjs/draw.js +1 -1
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +17 -3
- package/src/cjs/drawutilssvg.js +97 -91
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/geomutils.js +2 -2
- package/src/cjs/geomutils.js.map +1 -1
- package/src/cjs/index.js +5 -1
- package/src/cjs/index.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +2 -2
- package/src/cjs/interfaces/core.d.ts +3 -3
- package/src/cjs/interfaces/index.js +5 -1
- package/src/cjs/interfaces/index.js.map +1 -1
- package/src/cjs/utils/NGons.d.ts +13 -0
- package/src/cjs/utils/NGons.js +36 -0
- package/src/cjs/utils/NGons.js.map +1 -0
- package/src/cjs/utils/Params.js.map +1 -1
- package/src/cjs/utils/WebColors.js.map +1 -1
- package/src/cjs/utils/WebColorsContrast.js +1 -1
- package/src/cjs/utils/WebColorsContrast.js.map +1 -1
- package/src/cjs/utils/algorithms/CatmullRomPath.js.map +1 -1
- package/src/cjs/utils/algorithms/CircleIntersections.d.ts +3 -2
- package/src/cjs/utils/algorithms/CircleIntersections.js +12 -20
- package/src/cjs/utils/algorithms/CircleIntersections.js.map +1 -1
- package/src/cjs/utils/algorithms/ContourLineDetection.js +5 -5
- package/src/cjs/utils/algorithms/ContourLineDetection.js.map +1 -1
- package/src/cjs/utils/algorithms/CubicSplinePath.js.map +1 -1
- package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/cjs/utils/algorithms/Metaballs.d.ts +30 -0
- package/src/cjs/utils/algorithms/Metaballs.js +114 -0
- package/src/cjs/utils/algorithms/Metaballs.js.map +1 -0
- package/src/cjs/utils/algorithms/arrayResize.d.ts +8 -0
- package/src/cjs/utils/algorithms/arrayResize.js +24 -0
- package/src/cjs/utils/algorithms/arrayResize.js.map +1 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -1
- package/src/cjs/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
- package/src/cjs/utils/algorithms/convexHull.js.map +1 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/cjs/utils/algorithms/delaunay.js.map +1 -1
- package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/cjs/utils/algorithms/detectPaths.js.map +1 -1
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/cjs/utils/algorithms/matrixFill.js +1 -1
- package/src/cjs/utils/algorithms/matrixFill.js.map +1 -1
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/cjs/utils/algorithms/sutherlandHodgman.js.map +1 -1
- package/src/cjs/utils/cloneVertexArray.js.map +1 -1
- package/src/cjs/utils/creategui.js +20 -12
- package/src/cjs/utils/datastructures/CircularIntervalSet.js.map +1 -1
- package/src/cjs/utils/datastructures/Color.d.ts +2 -1
- package/src/cjs/utils/datastructures/Color.js +35 -16
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/datastructures/DataGrid2d.d.ts +1 -1
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +1 -1
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/cjs/utils/datastructures/GenericPath.js.map +1 -1
- package/src/cjs/utils/datastructures/Girih.d.ts +3 -2
- package/src/cjs/utils/datastructures/Girih.js +2 -1
- package/src/cjs/utils/datastructures/Girih.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihBowtie.js +2 -0
- package/src/cjs/utils/datastructures/GirihBowtie.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihDecagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihDecagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihHexagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihHexagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihPenroseRhombus.js +3 -1
- package/src/cjs/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihPentagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihPentagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihRhombus.js +2 -0
- package/src/cjs/utils/datastructures/GirihRhombus.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihTile.js +4 -2
- package/src/cjs/utils/datastructures/GirihTile.js.map +1 -1
- package/src/cjs/utils/datastructures/Matrix4x4.js.map +1 -1
- package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/cjs/utils/datastructures/interfaces.d.ts +3 -3
- package/src/cjs/utils/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/getAvailableContainerSpace.js +1 -1
- package/src/cjs/utils/dom/getAvailableContainerSpace.js.map +1 -1
- package/src/cjs/utils/findInVertexArray.js.map +1 -1
- package/src/cjs/utils/gup.d.ts +8 -0
- package/src/cjs/utils/gup.js +8 -0
- package/src/cjs/utils/gup.js.map +1 -1
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +3 -2
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleHelper.d.ts +38 -3
- package/src/cjs/utils/helpers/CircleHelper.js +51 -11
- package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +47 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.js +85 -14
- package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/cjs/utils/io/FileDrop.d.ts +3 -3
- package/src/cjs/utils/io/FileDrop.js.map +1 -1
- package/src/cjs/utils/parsers/OBJParser.d.ts +2 -2
- package/src/cjs/utils/parsers/OBJParser.js.map +1 -1
- package/src/cjs/utils/parsers/STLParser.d.ts +4 -3
- package/src/cjs/utils/parsers/STLParser.js +62 -12
- package/src/cjs/utils/parsers/STLParser.js.map +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/types.d.ts +13 -13
- package/src/createDemoDrawables.js +48 -3
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CircleSector.d.ts +64 -1
- package/src/esm/CircleSector.js +121 -1
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Grid.js.map +1 -1
- package/src/esm/KeyHandler.d.ts +1 -1
- package/src/esm/KeyHandler.js +13 -13
- package/src/esm/KeyHandler.js.map +1 -1
- package/src/esm/Line.js.map +1 -1
- package/src/esm/MouseHandler.d.ts +2 -2
- package/src/esm/MouseHandler.js +4 -4
- package/src/esm/MouseHandler.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +1 -1
- package/src/esm/PlotBoilerplate.js +43 -29
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/VEllipseSector.js +1 -1
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +3 -2
- package/src/esm/Vertex.js +9 -3
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/VertexAttr.d.ts +2 -1
- package/src/esm/VertexAttr.js +2 -1
- package/src/esm/VertexAttr.js.map +1 -1
- package/src/esm/VertexListeners.d.ts +1 -1
- package/src/esm/VertexListeners.js.map +1 -1
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +17 -3
- package/src/esm/drawutilssvg.js +28 -22
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/geomutils.js +2 -2
- package/src/esm/geomutils.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +2 -2
- package/src/esm/interfaces/core.d.ts +3 -3
- package/src/esm/utils/NGons.d.ts +13 -0
- package/src/esm/utils/NGons.js +33 -0
- package/src/esm/utils/NGons.js.map +1 -0
- package/src/esm/utils/Params.js.map +1 -1
- package/src/esm/utils/WebColors.js.map +1 -1
- package/src/esm/utils/algorithms/CatmullRomPath.js.map +1 -1
- package/src/esm/utils/algorithms/CircleIntersections.d.ts +3 -2
- package/src/esm/utils/algorithms/CircleIntersections.js +11 -19
- package/src/esm/utils/algorithms/CircleIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/ContourLineDetection.js.map +1 -1
- package/src/esm/utils/algorithms/CubicSplinePath.js.map +1 -1
- package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/esm/utils/algorithms/Metaballs.d.ts +30 -0
- package/src/esm/utils/algorithms/Metaballs.js +109 -0
- package/src/esm/utils/algorithms/Metaballs.js.map +1 -0
- package/src/esm/utils/algorithms/arrayResize.d.ts +8 -0
- package/src/esm/utils/algorithms/arrayResize.js +20 -0
- package/src/esm/utils/algorithms/arrayResize.js.map +1 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -1
- package/src/esm/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
- package/src/esm/utils/algorithms/convexHull.js.map +1 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/esm/utils/algorithms/delaunay.js.map +1 -1
- package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/matrixFill.js.map +1 -1
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/esm/utils/algorithms/sutherlandHodgman.js.map +1 -1
- package/src/esm/utils/cloneVertexArray.js.map +1 -1
- package/src/esm/utils/datastructures/CircularIntervalSet.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +2 -1
- package/src/esm/utils/datastructures/Color.js +33 -14
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/datastructures/DataGrid2d.d.ts +1 -1
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/esm/utils/datastructures/GenericPath.js.map +1 -1
- package/src/esm/utils/datastructures/Girih.d.ts +3 -2
- package/src/esm/utils/datastructures/Girih.js +2 -1
- package/src/esm/utils/datastructures/Girih.js.map +1 -1
- package/src/esm/utils/datastructures/GirihBowtie.js.map +1 -1
- package/src/esm/utils/datastructures/GirihDecagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihHexagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihPenroseRhombus.js +1 -1
- package/src/esm/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
- package/src/esm/utils/datastructures/GirihPentagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihRhombus.js.map +1 -1
- package/src/esm/utils/datastructures/GirihTile.js.map +1 -1
- package/src/esm/utils/datastructures/Matrix4x4.js.map +1 -1
- package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/esm/utils/datastructures/interfaces.d.ts +3 -3
- package/src/esm/utils/detectDarkMode.js.map +1 -1
- package/src/esm/utils/findInVertexArray.js.map +1 -1
- package/src/esm/utils/gup.d.ts +8 -0
- package/src/esm/utils/gup.js +8 -0
- package/src/esm/utils/gup.js.map +1 -1
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +3 -2
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleHelper.d.ts +38 -3
- package/src/esm/utils/helpers/CircleHelper.js +51 -11
- package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleSectorHelper.d.ts +47 -1
- package/src/esm/utils/helpers/CircleSectorHelper.js +85 -14
- package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/esm/utils/io/FileDrop.d.ts +3 -3
- package/src/esm/utils/io/FileDrop.js.map +1 -1
- package/src/esm/utils/parsers/OBJParser.d.ts +2 -2
- package/src/esm/utils/parsers/OBJParser.js.map +1 -1
- package/src/esm/utils/parsers/STLParser.d.ts +4 -3
- package/src/esm/utils/parsers/STLParser.js +63 -13
- package/src/esm/utils/parsers/STLParser.js.map +1 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/types.d.ts +13 -13
- package/src/index-gl.js +77 -85
- package/src/index.js +124 -129
- package/src/ts/CircleSector.ts +134 -3
- package/src/ts/PlotBoilerplate.ts +20 -11
- package/src/ts/Vertex.ts +8 -3
- package/src/ts/VertexAttr.ts +3 -2
- package/src/ts/drawutilssvg.ts +38 -25
- package/src/ts/geomutils.ts +60 -64
- package/src/ts/interfaces/DrawLib.ts +0 -15
- package/src/ts/utils/NGons.ts +35 -0
- package/src/ts/utils/algorithms/CircleIntersections.ts +280 -288
- package/src/ts/utils/algorithms/Metaballs.ts +144 -0
- package/src/ts/utils/algorithms/arrayResize.ts +22 -0
- package/src/ts/utils/datastructures/Color.ts +39 -15
- package/src/ts/utils/datastructures/Girih.ts +9 -8
- package/src/ts/utils/gup.ts +10 -2
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +9 -8
- package/src/ts/utils/helpers/CircleHelper.ts +70 -22
- package/src/ts/utils/helpers/CircleSectorHelper.ts +101 -17
- package/src/ts/utils/parsers/STLParser.ts +50 -16
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @author Ikaros Kappler
|
|
3
3
|
* @date 2020-10-05
|
|
4
4
|
* @modified 2021-02-08 Fixed a lot of es2015 compatibility issues.
|
|
5
|
-
* @
|
|
5
|
+
* @modified 2024-02-23 Fixed some null-type conflicts.
|
|
6
|
+
* @version 1.0.2
|
|
6
7
|
* @file CircleIntersections
|
|
7
8
|
* @public
|
|
8
9
|
**/
|
|
@@ -15,9 +16,8 @@ import { Line } from "../../Line";
|
|
|
15
16
|
import { CircularIntervalSet } from "../datastructures/CircularIntervalSet";
|
|
16
17
|
import { Interval, IndexPair, Matrix } from "../datastructures/interfaces";
|
|
17
18
|
|
|
18
|
-
|
|
19
19
|
/**
|
|
20
|
-
* @classdesc A script for finding the intersection points of two or
|
|
20
|
+
* @classdesc A script for finding the intersection points of two or
|
|
21
21
|
* multiple circles (the 'radical lines').
|
|
22
22
|
*
|
|
23
23
|
* Based on the C++ implementation by Robert King
|
|
@@ -35,303 +35,295 @@ import { Interval, IndexPair, Matrix } from "../datastructures/interfaces";
|
|
|
35
35
|
* @requires CirularIntervalSet
|
|
36
36
|
*/
|
|
37
37
|
export class CircleIntersections {
|
|
38
|
+
/**
|
|
39
|
+
* Find all connected outer path partitions.
|
|
40
|
+
*
|
|
41
|
+
* @method findOuterPartitions
|
|
42
|
+
* @static
|
|
43
|
+
* @memberof CircleIntersections
|
|
44
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
45
|
+
* @param {Array<CircularIntervalSet>} intervalSets - The determined interval sets (see `findOuterCircleIntervals`).
|
|
46
|
+
* @return {Array<Array<IndexPair>>} An array of paths, each defined by a sequence of IndexPairs adressing circle i and interval j.
|
|
47
|
+
**/
|
|
48
|
+
static findOuterPartitions(circles: Array<Circle>, intervalSets: Array<CircularIntervalSet>): Array<Array<IndexPair>> {
|
|
49
|
+
// For tracking which interval we already used for detecting the partition
|
|
50
|
+
// we need a matrix; find the maximal interval length.
|
|
51
|
+
let maxSetLength: number = 0;
|
|
52
|
+
for (var i = 0; i < intervalSets.length; i++) {
|
|
53
|
+
maxSetLength = Math.max(maxSetLength, intervalSets[i].intervals.length);
|
|
54
|
+
}
|
|
55
|
+
const usedIntervals: Matrix<boolean> = matrixFill<boolean>(intervalSets.length, maxSetLength, false);
|
|
38
56
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* @memberof CircleIntersections
|
|
45
|
-
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
46
|
-
* @param {Array<CircularIntervalSet>} intervalSets - The determined interval sets (see `findOuterCircleIntervals`).
|
|
47
|
-
* @return {Array<Array<IndexPair>>} An array of paths, each defined by a sequence of IndexPairs adressing circle i and interval j.
|
|
48
|
-
**/
|
|
49
|
-
static findOuterPartitions( circles:Array<Circle>,
|
|
50
|
-
intervalSets:Array<CircularIntervalSet>
|
|
51
|
-
) : Array<Array<IndexPair>> {
|
|
52
|
-
|
|
53
|
-
// For tracking which interval we already used for detecting the partition
|
|
54
|
-
// we need a matrix; find the maximal interval length.
|
|
55
|
-
let maxSetLength : number = 0;
|
|
56
|
-
for( var i = 0; i < intervalSets.length; i++ ) {
|
|
57
|
-
maxSetLength = Math.max( maxSetLength, intervalSets[i].intervals.length );
|
|
58
|
-
}
|
|
59
|
-
const usedIntervals : Matrix<boolean> = matrixFill<boolean>( intervalSets.length, maxSetLength, false );
|
|
60
|
-
|
|
61
|
-
var path : Array<IndexPair>|null = null;
|
|
62
|
-
var pathList : Array<Array<IndexPair>> = [];
|
|
63
|
-
while( (path = CircleIntersections.findOuterPartition(circles,intervalSets,usedIntervals)) != null ) {
|
|
64
|
-
pathList.push( path );
|
|
65
|
-
}
|
|
57
|
+
var path: Array<IndexPair> | null = null;
|
|
58
|
+
var pathList: Array<Array<IndexPair>> = [];
|
|
59
|
+
while ((path = CircleIntersections.findOuterPartition(circles, intervalSets, usedIntervals)) != null) {
|
|
60
|
+
pathList.push(path);
|
|
61
|
+
}
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
return pathList;
|
|
64
|
+
}
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Find all connected outer path partitions (as CircleSectors).
|
|
68
|
+
*
|
|
69
|
+
* @method findOuterPartitionsAsSectors
|
|
70
|
+
* @static
|
|
71
|
+
* @memberof CircleIntersections
|
|
72
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
73
|
+
* @param {Array<CircularIntervalSet>} intervalSets - The determined interval sets (see `findOuterCircleIntervals`).
|
|
74
|
+
* @return {Array<Array<CircleSector>>} An array of paths, each defined by a sequence of SircleSectors.
|
|
75
|
+
**/
|
|
76
|
+
static findOuterPartitionsAsSectors(
|
|
77
|
+
circles: Array<Circle>,
|
|
78
|
+
intervalSets: Array<CircularIntervalSet>
|
|
79
|
+
): Array<Array<CircleSector>> {
|
|
80
|
+
const partitions: Array<Array<IndexPair>> = CircleIntersections.findOuterPartitions(circles, intervalSets);
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Build the n*n intersection matrix: contains the radical line at (i,j) if circle i and circle j do intersect;
|
|
103
|
-
* conatins null at (i,j) otherwise.
|
|
104
|
-
*
|
|
105
|
-
* Note that this matrix is symmetrical: if circles (i,j) intersect with line (A,B), then also circles (j,i) intersect
|
|
106
|
-
* with line (B,A).
|
|
107
|
-
*
|
|
108
|
-
* The returned two-dimensional matrix (array) has exactly as many entries as the passed circle array.
|
|
109
|
-
*
|
|
110
|
-
* @method buildRadicalLineMatrix
|
|
111
|
-
* @static
|
|
112
|
-
* @memberof CircleIntersections
|
|
113
|
-
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
114
|
-
* @return {Array<Array<Line>>} A 2d-matrix containing the radical lines where circles intersect.
|
|
115
|
-
**/
|
|
116
|
-
static buildRadicalLineMatrix( circles:Array<Circle> ) : Matrix<Line> {
|
|
117
|
-
var radicalLines:Array<Array<Line>> = [];
|
|
118
|
-
for( var i = 0; i < circles.length; i++ ) {
|
|
119
|
-
if( !radicalLines[i] )
|
|
120
|
-
radicalLines[i] = arrayFill<Line>( circles.length, null ); // Array<Line>( circles.length );
|
|
121
|
-
for( var j = 0; j < circles.length; j++ ) {
|
|
122
|
-
if( i == j )
|
|
123
|
-
continue;
|
|
124
|
-
if( radicalLines[i][j] )
|
|
125
|
-
continue;
|
|
126
|
-
radicalLines[i][j] = circles[i].circleIntersection( circles[j] );
|
|
127
|
-
// Build symmetrical matrix
|
|
128
|
-
if( radicalLines[i][j] ) {
|
|
129
|
-
if( !radicalLines[j] )
|
|
130
|
-
radicalLines[j] = arrayFill<Line>( circles.length, null ); // Array<Line>( circles.length );
|
|
131
|
-
// Use reverse line
|
|
132
|
-
radicalLines[j][i] = new Line( radicalLines[i][j].b, radicalLines[i][j].a );
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return radicalLines;
|
|
137
|
-
};
|
|
82
|
+
const partitionsAsArcs: Array<Array<CircleSector>> = [];
|
|
83
|
+
for (var p = 0; p < partitions.length; p++) {
|
|
84
|
+
const path: Array<IndexPair> = partitions[p];
|
|
85
|
+
const pathAsArcs: Array<CircleSector> = [];
|
|
86
|
+
for (var i = 0; i < path.length; i++) {
|
|
87
|
+
const circleIndex: number = path[i].i;
|
|
88
|
+
const circle: Circle = circles[circleIndex];
|
|
89
|
+
var interval = intervalSets[path[i].i].intervals[path[i].j];
|
|
90
|
+
// Params: circle, startAngle, endAngle
|
|
91
|
+
pathAsArcs.push(new CircleSector(circle, interval[0], interval[1]));
|
|
92
|
+
} // END for
|
|
93
|
+
partitionsAsArcs.push(pathAsArcs);
|
|
94
|
+
} // END for
|
|
95
|
+
return partitionsAsArcs;
|
|
96
|
+
}
|
|
138
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Build the n*n intersection matrix: contains the radical line at (i,j) if circle i and circle j do intersect;
|
|
100
|
+
* conatins null at (i,j) otherwise.
|
|
101
|
+
*
|
|
102
|
+
* Note that this matrix is symmetrical: if circles (i,j) intersect with line (A,B), then also circles (j,i) intersect
|
|
103
|
+
* with line (B,A).
|
|
104
|
+
*
|
|
105
|
+
* The returned two-dimensional matrix (array) has exactly as many entries as the passed circle array.
|
|
106
|
+
*
|
|
107
|
+
* @method buildRadicalLineMatrix
|
|
108
|
+
* @static
|
|
109
|
+
* @memberof CircleIntersections
|
|
110
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
111
|
+
* @return {Array<Array<Line>>} A 2d-matrix containing the radical lines where circles intersect.
|
|
112
|
+
**/
|
|
113
|
+
static buildRadicalLineMatrix(circles: Array<Circle>): Matrix<Line | null> {
|
|
114
|
+
var radicalLines: Array<Array<Line | null>> = [];
|
|
115
|
+
for (var i = 0; i < circles.length; i++) {
|
|
116
|
+
if (!radicalLines[i]) {
|
|
117
|
+
radicalLines[i] = arrayFill<Line | null>(circles.length, null);
|
|
118
|
+
}
|
|
119
|
+
for (var j = 0; j < circles.length; j++) {
|
|
120
|
+
if (i == j) continue;
|
|
121
|
+
if (radicalLines[i][j]) continue;
|
|
122
|
+
radicalLines[i][j] = circles[i].circleIntersection(circles[j]);
|
|
123
|
+
// Build symmetrical matrix
|
|
124
|
+
var tmpRadLine = radicalLines[i][j];
|
|
125
|
+
if (tmpRadLine) {
|
|
126
|
+
if (!radicalLines[j]) {
|
|
127
|
+
radicalLines[j] = arrayFill<Line | null>(circles.length, null);
|
|
128
|
+
}
|
|
129
|
+
// Use reverse line
|
|
130
|
+
radicalLines[j][i] = new Line(tmpRadLine.b, tmpRadLine.a);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return radicalLines;
|
|
135
|
+
}
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
137
|
+
/**
|
|
138
|
+
* Find all circles (indices) which are completely located inside another circle.
|
|
139
|
+
*
|
|
140
|
+
* The returned array conatins the array indices.
|
|
141
|
+
*
|
|
142
|
+
* @method findInnerCircles
|
|
143
|
+
* @static
|
|
144
|
+
* @memberof CircleIntersections
|
|
145
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
146
|
+
* @return {Array<number>}
|
|
147
|
+
**/
|
|
148
|
+
static findInnerCircles(circles: Array<Circle>): Array<number> {
|
|
149
|
+
const innerCircleIndices: Array<number> = [];
|
|
150
|
+
for (var i = 0; i < circles.length; i++) {
|
|
151
|
+
for (var j = 0; j < circles.length; j++) {
|
|
152
|
+
if (i == j) continue;
|
|
153
|
+
if (circles[j].containsCircle(circles[i])) {
|
|
154
|
+
innerCircleIndices.push(i);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return innerCircleIndices;
|
|
159
|
+
}
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return intervalSets;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Calculate the next connected partition from the given set of circles and outer path intervals. The function
|
|
200
|
-
* will pick a random unused circle interval and detect all adjacent intervals until a closed partition
|
|
201
|
-
* was found.
|
|
202
|
-
*
|
|
203
|
-
* If an interval (circle section) was already visited will be stored in the `usedIntervalSetRecords` matrix (thus
|
|
204
|
-
* is must be large enough to map all sections).
|
|
205
|
-
*
|
|
206
|
-
* The returned array contains IndexPairs (i,j) - one for each circle i - indicating the used circle section j.
|
|
207
|
-
*
|
|
208
|
-
* @method findOuterPartition
|
|
209
|
-
* @static
|
|
210
|
-
* @memberof CircleIntersections
|
|
211
|
-
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
212
|
-
* @param {Array<CircularIntervalSet>} intervalSets - The circle intervals that form the intersection outline.
|
|
213
|
-
* @param {Matrix<boolean>} usedIntervals - A matrix for remembering which circle intervals were always used.
|
|
214
|
-
* @return {Array<Indexpair>|null} The next partition or `null` if no more can be found.
|
|
215
|
-
**/
|
|
216
|
-
static findOuterPartition( circles:Array<Circle>,
|
|
217
|
-
intervalSets:Array<CircularIntervalSet>,
|
|
218
|
-
usedIntervals:Matrix<boolean>
|
|
219
|
-
) : Array<IndexPair>|null {
|
|
220
|
-
let intLocation : IndexPair = CircleIntersections.randomUnusedInterval( intervalSets, usedIntervals );
|
|
221
|
-
const path : Array<IndexPair> = [];
|
|
222
|
-
while( intLocation != null ) {
|
|
223
|
-
path.push( intLocation );
|
|
224
|
-
usedIntervals[ intLocation.i ][ intLocation.j ] = true;
|
|
225
|
-
intLocation = CircleIntersections.findAdjacentInterval( circles, intLocation, intervalSets, usedIntervals, 0.001 );
|
|
226
|
-
};
|
|
227
|
-
return path.length == 0 ? null : path;
|
|
228
|
-
};
|
|
229
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Calculate all outer circle intervals (sections that belong to the outermost line), dermined by the given
|
|
163
|
+
* circles and their radical lines.
|
|
164
|
+
*
|
|
165
|
+
* The returned array contains IntervalSets - one for each circle - indicating the remaining circle sections.
|
|
166
|
+
*
|
|
167
|
+
* @method findOuterCircleIntervals
|
|
168
|
+
* @static
|
|
169
|
+
* @memberof CircleIntersections
|
|
170
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
171
|
+
* @param {Array<Line>} intersectionMatrix
|
|
172
|
+
* @return {Array<number>}
|
|
173
|
+
**/
|
|
174
|
+
static findOuterCircleIntervals(circles: Array<Circle>, intersectionMatrix: Matrix<Line>): Array<CircularIntervalSet> {
|
|
175
|
+
const intervalSets: Array<CircularIntervalSet> = [];
|
|
176
|
+
for (var i = 0; i < circles.length; i++) {
|
|
177
|
+
intervalSets[i] = new CircularIntervalSet(0, 2 * Math.PI);
|
|
178
|
+
for (var j = 0; j < circles.length; j++) {
|
|
179
|
+
if (i == j) continue;
|
|
180
|
+
if (intersectionMatrix[i][j] !== null) {
|
|
181
|
+
// const interval : Interval = CircleIntersections.radicalLineToInterval( circle, radicalLine );
|
|
182
|
+
CircleIntersections.handleCircleInterval(circles[i], intersectionMatrix[i][j], intervalSets[i]);
|
|
183
|
+
} else if (circles[j].containsCircle(circles[i])) {
|
|
184
|
+
intervalSets[i].clear();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return intervalSets;
|
|
189
|
+
}
|
|
230
190
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Calculate the next connected partition from the given set of circles and outer path intervals. The function
|
|
193
|
+
* will pick a random unused circle interval and detect all adjacent intervals until a closed partition
|
|
194
|
+
* was found.
|
|
195
|
+
*
|
|
196
|
+
* If an interval (circle section) was already visited will be stored in the `usedIntervalSetRecords` matrix (thus
|
|
197
|
+
* is must be large enough to map all sections).
|
|
198
|
+
*
|
|
199
|
+
* The returned array contains IndexPairs (i,j) - one for each circle i - indicating the used circle section j.
|
|
200
|
+
*
|
|
201
|
+
* @method findOuterPartition
|
|
202
|
+
* @static
|
|
203
|
+
* @memberof CircleIntersections
|
|
204
|
+
* @param {Array<Circle>} circles - The circles to find intersections for.
|
|
205
|
+
* @param {Array<CircularIntervalSet>} intervalSets - The circle intervals that form the intersection outline.
|
|
206
|
+
* @param {Matrix<boolean>} usedIntervals - A matrix for remembering which circle intervals were always used.
|
|
207
|
+
* @return {Array<Indexpair>|null} The next partition or `null` if no more can be found.
|
|
208
|
+
**/
|
|
209
|
+
static findOuterPartition(
|
|
210
|
+
circles: Array<Circle>,
|
|
211
|
+
intervalSets: Array<CircularIntervalSet>,
|
|
212
|
+
usedIntervals: Matrix<boolean>
|
|
213
|
+
): Array<IndexPair> | null {
|
|
214
|
+
let intLocation: IndexPair | null = CircleIntersections.randomUnusedInterval(intervalSets, usedIntervals);
|
|
215
|
+
const path: Array<IndexPair> = [];
|
|
216
|
+
while (intLocation != null) {
|
|
217
|
+
path.push(intLocation);
|
|
218
|
+
usedIntervals[intLocation.i][intLocation.j] = true;
|
|
219
|
+
intLocation = CircleIntersections.findAdjacentInterval(circles, intLocation, intervalSets, usedIntervals, 0.001);
|
|
220
|
+
}
|
|
221
|
+
return path.length == 0 ? null : path;
|
|
222
|
+
}
|
|
246
223
|
|
|
247
|
-
|
|
248
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Convert a radical line (belonging to a circle) into an interval: start angle and end angle.
|
|
226
|
+
*
|
|
227
|
+
* @method radicalLineToInterval
|
|
228
|
+
* @static
|
|
229
|
+
* @private
|
|
230
|
+
* @memberof CircleIntersections
|
|
231
|
+
* @param {Circle} circle - The circle itself.
|
|
232
|
+
* @param {Line} radicaLine - The radical line to convert (must have two intersection points on the circle).
|
|
233
|
+
* @return {Interval} The interval `[startAngle,endAngle]` determined by the radical line.
|
|
234
|
+
**/
|
|
235
|
+
private static radicalLineToInterval(circle: Circle, radicalLine: Line): Interval {
|
|
236
|
+
// Get angle sections in the circles
|
|
237
|
+
const lineA: Line = new Line(circle.center, radicalLine.a);
|
|
238
|
+
const lineB: Line = new Line(circle.center, radicalLine.b);
|
|
249
239
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if( angleA < 0 ) angleA = Math.PI*2 + angleA;
|
|
253
|
-
if( angleB < 0 ) angleB = Math.PI*2 + angleB;
|
|
240
|
+
let angleA: number = lineA.angle();
|
|
241
|
+
let angleB: number = lineB.angle();
|
|
254
242
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
243
|
+
// Map angles to [0 ... 2*PI]
|
|
244
|
+
// (the angle() function might return negative angles in [-PI .. 0 .. PI])
|
|
245
|
+
if (angleA < 0) angleA = Math.PI * 2 + angleA;
|
|
246
|
+
if (angleB < 0) angleB = Math.PI * 2 + angleB;
|
|
258
247
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*
|
|
262
|
-
* It applies the passed radical line by intersecting the remaining circle sections with the new section.
|
|
263
|
-
*
|
|
264
|
-
* @method handleCircleInterval
|
|
265
|
-
* @static
|
|
266
|
-
* @private
|
|
267
|
-
* @memberof CircleIntersections
|
|
268
|
-
* @param {Circle} circle - The circles to find intersections for.
|
|
269
|
-
* @param {Line} radicalLine - The radical line to apply.
|
|
270
|
-
* @param {CircularIntervalSet} intervalSet - The CircularIntervalSet to use (must have left and right border: 0 and 2*PI).
|
|
271
|
-
* @return {void}
|
|
272
|
-
**/
|
|
273
|
-
private static handleCircleInterval( circle : Circle, radicalLine : Line, intervalSet : CircularIntervalSet ) : void {
|
|
274
|
-
const interval : Interval = CircleIntersections.radicalLineToInterval( circle, radicalLine );
|
|
275
|
-
intervalSet.intersect( interval[1], interval[0] );
|
|
276
|
-
};
|
|
277
|
-
|
|
248
|
+
return [angleA, angleB];
|
|
249
|
+
}
|
|
278
250
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
};
|
|
251
|
+
/**
|
|
252
|
+
* This is a helper fuction used by `findOuterCircleIntervals`.
|
|
253
|
+
*
|
|
254
|
+
* It applies the passed radical line by intersecting the remaining circle sections with the new section.
|
|
255
|
+
*
|
|
256
|
+
* @method handleCircleInterval
|
|
257
|
+
* @static
|
|
258
|
+
* @private
|
|
259
|
+
* @memberof CircleIntersections
|
|
260
|
+
* @param {Circle} circle - The circles to find intersections for.
|
|
261
|
+
* @param {Line} radicalLine - The radical line to apply.
|
|
262
|
+
* @param {CircularIntervalSet} intervalSet - The CircularIntervalSet to use (must have left and right border: 0 and 2*PI).
|
|
263
|
+
* @return {void}
|
|
264
|
+
**/
|
|
265
|
+
private static handleCircleInterval(circle: Circle, radicalLine: Line, intervalSet: CircularIntervalSet): void {
|
|
266
|
+
const interval: Interval = CircleIntersections.radicalLineToInterval(circle, radicalLine);
|
|
267
|
+
intervalSet.intersect(interval[1], interval[0]);
|
|
268
|
+
}
|
|
302
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Pick a random unused circle interval. This function is used by the `findOuterPartition` function, which
|
|
272
|
+
* starts the detection with any random section.
|
|
273
|
+
*
|
|
274
|
+
* @method randomUnusedInterval
|
|
275
|
+
* @static
|
|
276
|
+
* @private
|
|
277
|
+
* @memberof CircleIntersections
|
|
278
|
+
* @param {Array<CircularIntervalSet>} intervalSets - An array of all available interval sets/intervals.
|
|
279
|
+
* @param {Matrix<boolean>} usedIntervals - A matrix indicating which intervals have already been used/visited by the algorithm
|
|
280
|
+
* @return {IndexPair|null}
|
|
281
|
+
**/
|
|
282
|
+
private static randomUnusedInterval(
|
|
283
|
+
intervalSets: Array<CircularIntervalSet>,
|
|
284
|
+
usedIntervals: Matrix<boolean>
|
|
285
|
+
): IndexPair | null {
|
|
286
|
+
for (var i = 0; i < intervalSets.length; i++) {
|
|
287
|
+
for (var j = 0; j < intervalSets[i].intervals.length; j++) {
|
|
288
|
+
if (!usedIntervals[i][j]) {
|
|
289
|
+
return { i: i, j: j };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
303
295
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
296
|
+
/**
|
|
297
|
+
* Find the next adjacent circle interval for the given interval.
|
|
298
|
+
* starts the detection with any random section.
|
|
299
|
+
*
|
|
300
|
+
* @method randomUnusedInterval
|
|
301
|
+
* @static
|
|
302
|
+
* @private
|
|
303
|
+
* @memberof CircleIntersections
|
|
304
|
+
* @param {Array<CircularIntervalSet>} intervalSets - An array of all available interval sets/intervals.
|
|
305
|
+
* @param {Matrix<boolean>} usedIntervals - A matrix indicating which intervals have already been used/visited by the algorithm
|
|
306
|
+
* @return {IndexPair|null}
|
|
307
|
+
**/
|
|
308
|
+
private static findAdjacentInterval(
|
|
309
|
+
circles: Array<Circle>,
|
|
310
|
+
intLocation: IndexPair,
|
|
311
|
+
intervalSets: Array<CircularIntervalSet>,
|
|
312
|
+
usedIntervalSetRecords: Matrix<boolean>,
|
|
313
|
+
epsilon: number
|
|
314
|
+
) {
|
|
315
|
+
var curInterval = intervalSets[intLocation.i].intervals[intLocation.j];
|
|
316
|
+
var curEndPoint = circles[intLocation.i].vertAt(curInterval[1]);
|
|
317
|
+
for (var i = 0; i < intervalSets.length; i++) {
|
|
318
|
+
for (var j = 0; j < intervalSets[i].intervals.length; j++) {
|
|
319
|
+
if (usedIntervalSetRecords[i][j]) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
var interval = intervalSets[i].intervals[j];
|
|
323
|
+
var startPoint = circles[i].vertAt(interval[0]);
|
|
324
|
+
if (curEndPoint.distance(startPoint) < epsilon) return { i: i, j: j };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
}
|