Classdesc

A script for finding the intersection points of two or multiple circles (the 'radical lines').

Based on the C++ implementation by Robert King https://stackoverflow.com/questions/3349125/circle-circle-intersection-points and the 'Circles and spheres' article by Paul Bourke. http://paulbourke.net/geometry/circlesphere/

Requires

arrayFill

Requires

matrixFill

Requires

Circle

Requires

IndexPair

Requires

Matrix

Requires

Interval

Requires

Line

Requires

CirularIntervalSet

Constructors

Methods

  • Build the n*n intersection matrix: contains the radical line at (i,j) if circle i and circle j do intersect; conatins null at (i,j) otherwise.

    Note that this matrix is symmetrical: if circles (i,j) intersect with line (A,B), then also circles (j,i) intersect with line (B,A).

    The returned two-dimensional matrix (array) has exactly as many entries as the passed circle array.

    Parameters

    • circles: Circle[]

      The circles to find intersections for.

    Returns Matrix<Line>

    A 2d-matrix containing the radical lines where circles intersect.

    Method

    buildRadicalLineMatrix

    Static

    Memberof

    CircleIntersections

  • Private

    Find the next adjacent circle interval for the given interval. starts the detection with any random section.

    Parameters

    Returns {
        i: number;
        j: number;
    }

    • i: number
    • j: number

    Method

    randomUnusedInterval

    Static

    Memberof

    CircleIntersections

  • Find all circles (indices) which are completely located inside another circle.

    The returned array conatins the array indices.

    Parameters

    • circles: Circle[]

      The circles to find intersections for.

    Returns number[]

    Method

    findInnerCircles

    Static

    Memberof

    CircleIntersections

  • Calculate the next connected partition from the given set of circles and outer path intervals. The function will pick a random unused circle interval and detect all adjacent intervals until a closed partition was found.

    If an interval (circle section) was already visited will be stored in the usedIntervalSetRecords matrix (thus is must be large enough to map all sections).

    The returned array contains IndexPairs (i,j) - one for each circle i - indicating the used circle section j.

    Parameters

    • circles: Circle[]

      The circles to find intersections for.

    • intervalSets: CircularIntervalSet[]

      The circle intervals that form the intersection outline.

    • usedIntervals: Matrix<boolean>

      A matrix for remembering which circle intervals were always used.

    Returns IndexPair[]

    The next partition or null if no more can be found.

    Method

    findOuterPartition

    Static

    Memberof

    CircleIntersections

  • Private

    This is a helper fuction used by findOuterCircleIntervals.

    It applies the passed radical line by intersecting the remaining circle sections with the new section.

    Parameters

    • circle: Circle

      The circles to find intersections for.

    • radicalLine: Line

      The radical line to apply.

    • intervalSet: CircularIntervalSet

      The CircularIntervalSet to use (must have left and right border: 0 and 2*PI).

    Returns void

    Method

    handleCircleInterval

    Static

    Memberof

    CircleIntersections

  • Private

    Pick a random unused circle interval. This function is used by the findOuterPartition function, which starts the detection with any random section.

    Parameters

    • intervalSets: CircularIntervalSet[]

      An array of all available interval sets/intervals.

    • usedIntervals: Matrix<boolean>

      A matrix indicating which intervals have already been used/visited by the algorithm

    Returns IndexPair

    Method

    randomUnusedInterval

    Static

    Memberof

    CircleIntersections