# Which package to use as a dependency for geometric primitives?

**URL:** <https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [July 30, 2023, 12:33pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268 "2023-07-30T12:33:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [July 30, 2023, 12:33pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/1 "2023-07-30T12:33:26Z")

</div>

I need to create method dispatch on geometric primitives: hypersphere and hyperrectangle (i want to create samplers that randomly sample points uniformly within these primitives).

I don’t want to re-define types for the primitives as I am sure there are several around. Which one to use? I want to avoid name clashes if e.g., someone uses Makie, then the same name should be used for a 3-sphere.

Can someone instruct me on which dependency to use, and how are hyperspheres and hyperrectangles called in this dependency?

---

<div class="post-metadata">

**Author:** ![skleinbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skleinbo/32/36080_2.png) [@skleinbo](https://discourse.julialang.org/u/skleinbo)\
**Post date:** [July 30, 2023, 1:14pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/2 "2023-07-30T13:14:53Z")

</div>

I suppose you are looking for GeometryBasics.jl ?

[https://juliageometry.github.io/GeometryBasics.jl/stable/](https://juliageometry.github.io/GeometryBasics.jl/stable/)

The primitives defines therein are used by Makie.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 30, 2023, 1:39pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/3 "2023-07-30T13:39:31Z")

</div>

We have all that implemented in Meshes.jl already @Datseris:

> **[GitHub - JuliaGeometry/Meshes.jl: Computational geometry and meshing...](https://github.com/JuliaGeometry/Meshes.jl)**
>
> Computational geometry and meshing algorithms in Julia - GitHub - JuliaGeometry/Meshes.jl: Computational geometry and meshing algorithms in Julia

Check the latest documentation, which is hosted in a separate repo as we transition to out-of-repo docs:

[https://juliageometry.github.io/MeshesDocs/dev/](https://juliageometry.github.io/MeshesDocs/dev/)

In particular, check the sampling section:

[https://juliageometry.github.io/MeshesDocs/dev/algorithms/sampling.html](https://juliageometry.github.io/MeshesDocs/dev/algorithms/sampling.html)

These sampling algorithms are used in GeoStats.jl to define spatial sthocastic processes:

[https://juliaearth.github.io/GeoStats.jl/latest/pointpatterns/pointprocs.html](https://juliaearth.github.io/GeoStats.jl/latest/pointpatterns/pointprocs.html)

There you will find examples with samples over the sphere.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [July 30, 2023, 2:24pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/4 "2023-07-30T14:24:14Z")

</div>

There’s [DomainSets.jl](https://github.com/JuliaApproximation/DomainSets.jl) that provides sets like hyperrects, spheres, and more. It builds on the very widely used `IntervalSets.jl`. Not sure about Makie and names it uses though.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [July 31, 2023, 11:51am UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/5 "2023-07-31T11:51:37Z")

</div>

@juliohm thanks, a question: how does this functionality scale with dimension? I am guessing you also use internally tuples to represent vectors. So this would mean that this functionality does not scale well as the state space dimension increases to much larger than 10?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 31, 2023, 11:58am UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/6 "2023-07-31T11:58:02Z")

</div>

That is correct @Datseris , our use cases are mainly 2D and 3D geometric processing. We did not aim for higher-dimensional spaces. I think you will not find a package that has this goal currently.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [July 31, 2023, 9:00pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/7 "2023-07-31T21:00:05Z")

</div>

> [@juliohm](#):
>
> I think you will not find a package that has this goal currently.

Ehm… (: No problems with arbitrary-dim spaces:

```julia
julia> using DomainSets

julia> Ball(10, [1,2,3])
Ball(10, [1, 2, 3])

julia> Ball(10, 1:1000)
Ball(10, [1, 2, 3, 4, ..., 999, 1000])

julia> Rectangle([i..(i+1) for i in 1:10^3])
(1..2) × (2..3) × (3..4) × ... × (1000..1001)

```

It uses whatever containers you provide: svectors, vectors.  
Not that well-documented, but lots of shape definitions there.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 31, 2023, 9:53pm UTC](https://discourse.julialang.org/t/which-package-to-use-as-a-dependency-for-geometric-primitives/102268/8 "2023-07-31T21:53:48Z")

</div>

Sorry, I meant with geometric processing and visualization features. Creating a sphere in D dimensions is trivial indeed 🙂
