DomainSets.jl
DomainSets.jl copied to clipboard
package extensions and interoperability with different domain types
At the start of DomainSets we identified a host of packages that did similar work (#14). There is an uncountable number of Julia packages defining a Point type!
The combination of package extensions with the improvements in DomainSets v0.7 towards domains-as-an-interface makes a lot more things possible. I'm experimenting with that in DomainSetsExtensions.jl. The mechanism of associating domains with "canonical domains" is essential here. It allows for automatic translation of types across packages.
Here is an example (works with master):
julia> using DomainSets, DomainSetsExtensions
julia> using Intervals, IntervalSets, GeometryBasics, Meshes
julia> d1 = Intervals.Interval(0.0, 1.0)
Intervals.Interval{Float64, Closed, Closed}(0.0, 1.0)
julia> d2 = IntervalSets.Interval(2.0, 3.0)
2.0 .. 3.0
julia> productdomain(d1, d2)
[0.0 .. 1.0] × (2.0 .. 3.0)
julia> isequaldomain( productdomain(d1, d2), Meshes.Box((0.0, 2.0), (1.0, 3.0)))
true
The code allows to combine domains of different types and different packages. It also automatically deduces that the cartesian product of an interval from Intervals.jl with an interval from IntervalSets.jl is equal to a Box as defined in Meshes.jl.
What's more: as soon as one package somewhere has the ability to plot a domain, we can borrow that functionality!
Proof of concept:
using DomainSets, DomainSetsExtensions, StaticArrays
using Meshes, CairoMakie
viz( 2 .* UnitCube() .+ SA[1.0,2.0,3.0])
On my setup in a notebook, this uses the plotting functionality of Meshes to show a cube defined in DomainSets.