Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package extensions and interoperability with different domain types #149

Open
daanhb opened this issue Feb 20, 2024 · 1 comment
Open

package extensions and interoperability with different domain types #149

daanhb opened this issue Feb 20, 2024 · 1 comment

Comments

@daanhb
Copy link
Member

daanhb commented Feb 20, 2024

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.

@daanhb
Copy link
Member Author

daanhb commented Feb 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant