# Class CircleIntersections

#### 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/

arrayFill

matrixFill

Circle

IndexPair

Matrix

Interval

Line

#### Requires

CirularIntervalSet

## 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.

#### Memberof

CircleIntersections

• `Private`

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

#### Method

randomUnusedInterval

#### 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.

#### Method

findInnerCircles

#### Memberof

CircleIntersections

• Calculate all outer circle intervals (sections that belong to the outermost line), dermined by the given circles and their radical lines.

The returned array contains IntervalSets - one for each circle - indicating the remaining circle sections.

#### Parameters

• circles: Circle[]

The circles to find intersections for.

• intersectionMatrix: Matrix<Line>

#### Method

findOuterCircleIntervals

#### 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

#### Memberof

CircleIntersections

• Find all connected outer path partitions.

#### Parameters

• circles: Circle[]

The circles to find intersections for.

• intervalSets: CircularIntervalSet[]

The determined interval sets (see `findOuterCircleIntervals`).

#### Returns IndexPair[][]

An array of paths, each defined by a sequence of IndexPairs adressing circle i and interval j.

#### Method

findOuterPartitions

#### Memberof

CircleIntersections

• Find all connected outer path partitions (as CircleSectors).

#### Parameters

• circles: Circle[]

The circles to find intersections for.

• intervalSets: CircularIntervalSet[]

The determined interval sets (see `findOuterCircleIntervals`).

#### Returns CircleSector[][]

An array of paths, each defined by a sequence of SircleSectors.

#### Method

findOuterPartitionsAsSectors

#### 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.

• intervalSet: CircularIntervalSet

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

#### Method

handleCircleInterval

#### Memberof

CircleIntersections

• `Private`

Convert a radical line (belonging to a circle) into an interval: start angle and end angle.

#### Parameters

• circle: Circle

The circle itself.

#### Returns Interval

The interval `[startAngle,endAngle]` determined by the radical line.

#### 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

#### Method

randomUnusedInterval

#### Memberof

CircleIntersections