Skip to content

Paths ​

A path is a sequence of AbstractCurve values that compose a continuous, complex-valued path. A path with components is parameterized over the interval , with the first component covering , the second covering , and so on. The path is checked for continuity at construction time.

Abstract interface ​

AbstractPath ​

Every AbstractPath type is expected to provide the following method:

  • curves(P): Return an array of the curves constituting P.

Default implementations are given for the following methods.

MethodDescription
curve(P, k::Integer)kth curve of P.
vertices(P)Vertices of P (the endpoints of the constituent curves)
vertex(P, k::Integer)kth vertex of P.
length(P)Number of curves in the path.
isfinite(P)True if the path is bounded.
point(P, t::Real)Point on the path.
point(P, t::AbstractVector)Vectorization of point.
tangent(P, t::Real)Complex-valued tangent at a point.
unittangent(P, t::Real)Normalized tangent at a point.
normal(P, t::Real)Leftward-pointing unit normal at a point.
conj(P)Complex conjugate of the path.
reverse(P)Reverse the orientation of the path.
+,-,*,/Translate, rotate and scale a path.
isapprox(P1, P2)Determine whether two values represent the same path.
arclength(P)Arc length of the path.
dist(z, P)Distance from a point to the path.
closest(z, P)Point on the path nearest to a given number.

Iterator interface

The AbstractPath type implements the eltype, length, getindex, and iterate methods of the standard Julia iterator interface. Therefore, clauses such as for c in P will iterate over the curves in P for loops, comprehensions, and generators.

AbstractClosedPath ​

The AbstractClosedPath subtype modifies a few of the implementations above:

MethodDescription
vertices(P)Only the unique vertices; i.e., does not duplicate the initial/final vertex.
curve(P, k)kth curve of the path in a circular/modulo sense.
vertex(P, k)kth vertex of the path in a circular/modulo sense.
point, tangent, unittangent, normalUse a circular/modulo interpretation of the parameter.

The AbstractClosedPath type also has default implementations for the following methods:

MethodDescription
winding(P, z)Winding number of P about z.
isinside(z, P)Detect whether z lies inside the path.
isoutside(z, C)Detect whether z lies outside the path.

Generic types ​

There are generic implementations of both of the abstract types described above.

Path ​

Path generically implements the AbstractPath type. A path is created by calling Path(c), where c is a vector of curves subtyped from AbstractCurve. The constructor tests the endpoints of the given curves for continuity up to a selectable tolerance.

ClosedPath ​

ClosedPath generically implements the AbstractClosedPath type. Its chief difference from the Path type is that the constructor also checks whether the initial and final points coincide (up to tolerance). As a subtype of AbstractClosedPath, this type also inherits the use of circular/modulo addressing for curve selection and parameterization.

Examples ​

Here is a path defined by arcs and segments.

julia
julia> a = Arc(-1, 1, -1im)
Arc{Float64} fraction 0.75 of Circle(0.0+0.0im, 1.0, cw) starting at 0.5

julia> right = Path([4 + 1im+a, 4-1im - 1im*a])
Path{Float64, Vector{Arc{Float64, ComplexF64}}} with 2 curves

julia> s = Segment(-3+1im, 3+1im)
Segment{Float64} from (-3.0 + 1.0im) to (3.0 + 1.0im)

julia> p = ClosedPath([s, right..., -s, -right...])
ClosedPath{Float64, Vector{ComplexRegions.AbstractCurve{Float64}}} with 6 curves

julia> arclength(p), vertices(p)
(30.84955592153876, ComplexF64[-3.0 + 1.0im, 3.0 + 1.0im, 4.0 + 0.0im, 3.0 - 1.0im, -3.0 - 1.0im, -4.0 + 0.0im])