Skip to main content

utils.lineIntersectsCircle()

The utils.lineIntersectsCircle() function finds the intersection between a line segment from point from to point to and a circle with its center at point center and a radius of radius mm.

Signature

array | false utils.lineIntersectsCircle(
Point center,
float radius,
Point from,
Point to,
string sort = 'x'
)

The 5th and last parameter controls the sorting of the found intersections. When this returns 2 intersections, you can choose how they are ordered in the returned array:

Set sort to:

  • x : The point with the lowest X-coordinate will go first (left to right)
  • y : The point with the lowest Y-coordinate will go first (top to bottom)

Example

A Utils.lineIntersectsCircle() example