Intersections

Methods are provided to find intersections between all the Specific subtypes. In the generic cases where the intersections consist of zero or more points, a vector of results is returned. In special circumstances of partially or wholly overlapping curves, a Curve subtype is returned.

There are also methods for finding the intersections between curves and paths, and between two paths. These return set unions over the curves of the path(s), returning a vector with complex element type or, if some overlaps occurred, mixed types.

Examples

Circles and Arcs intersect at zero, one, or two points, or as an Arc.

julia> c = Circle(0, 1)Circle{ComplexF64} in the complex plane:
   centered at (0.0 + 0.0im) with radius 1.0, positively oriented
julia> a = Arc(1+1im, 0, 1-1im)Arc{ComplexF64} in the complex plane: fraction 0.5 of (Circle(1.0+0.0im,1.0,ccw)) starting at 0.25
julia> intersect(c, a)2-element Vector{ComplexF64}: 0.5 - 0.8660254037844386im 0.5 + 0.8660254037844386im
julia> b = Arc(1im, 1, -1im)Arc{ComplexF64} in the complex plane: fraction 0.5 of (Circle(0.0+0.0im,1.0,cw)) starting at 0.75
julia> intersect(c, b)Arc{ComplexF64} in the complex plane: fraction 0.5 of (Circle(0.0+0.0im,1.0,cw)) starting at 0.75
julia> ans ≈ btrue

Segments and Lines intersect at zero or one point, or as a Line or Segment.

julia> l = Line(1im, 1+1im)Line{ComplexF64} in the complex plane:
   through (0.0 + 1.0im) parallel to (1.0 + 0.0im)
julia> s = Segment(-2, 2+2im)Segment{ComplexF64} in the complex plane: from (-2.0 + 0.0im) to (2.0 + 2.0im)
julia> intersect(l, s)1-element Vector{ComplexF64}: 0.0 + 1.0im
julia> intersect(l, s + 2im)Any[]
julia> intersect(s,Segment(-4-1im, 1im))Segment{ComplexF64} in the complex plane: from (-2.0 + 0.0im) to (0.0 + 1.0im)
julia> ℓ = Line(1/2, 1/2+1im)  # line through 0.5 and 0.5+1iLine{ComplexF64} in the complex plane:
   through (0.5 + 0.0im) parallel to (0.0 + 1.0im)
julia> c = 1 / ℓ # a circleCircle{ComplexF64} in the complex plane: centered at (1.0 - 2.7755575615628914e-17im) with radius 1.0, negatively oriented
julia> intersect(ℓ, c)2-element Vector{ComplexF64}: 0.5 + 0.8660254037844386im 0.5 - 0.8660254037844386im