Giter Club home page Giter Club logo

bubblebath.jl's People

Contributors

mastrof avatar

Watchers

 avatar

bubblebath.jl's Issues

Improve info logging

  • Introduce a verbose keyword to bubblebath and bubblebath! to turn on/off the info logs
  • Improve the info logs by providing more accurate information

Introduce other simple geometrical shapes

Cubes should be reasonably easy to implement; also cylinders, disks and parallelepipeds should be feasible.
The interface might need to be review a bit but I don't expect it to be a breaking change.

STL output

Need to implement functions to output .stl meshes.
ConstructiveGeometry.jl kind of works for this but seems not fully maintained, not sure if it's something that can be relied upon.

Generate walkmaps

Implement functions to generate walkmaps, i.e. a BitArray{D} taking value 0 in the space occupied by spheres, and 1 in free space.
The function should have a signature of the form
walkmap(bath::AbstractVector{Sphere{D}}, resolution::Real, probe_radius::Real=0; boundaries::Symbol=:cut) where D

The resulting walkmap depends on both the resolution of the mesh and a probe_radius.
The probe_radius can be imagined as the radius of a probe that is moving in the bath; the accessible volume of course depends on the radius.

Finally, the boundaries keyword can be used to determine what happens in case there are objects crossing through the domain boundaries. There will be two options: :cut and :wrap.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Use `bubblebath!` under the hood in `bubblebath`

The non in-place bubblebath

function bubblebath(
radii::Vector{<:Real},
extent::NTuple{D,Real};
min_distance::Real = 0.0,
through_boundaries = false,
max_tries = 10000,
max_fails = 100
)::Vector{Sphere{D}} where D
spheres = Sphere{D}[]
sizehint!(spheres, length(radii))
fails = 0
for radius in sort(radii, rev=true)
tries = 0
Δ = through_boundaries ? 0.0 : radius
while true
if tries > max_tries
if fails > max_fails
@info "Reached max. number of tries. Interrupting."
@goto packing_complete
else
fails += 1
break
end
end
pos = Δ .+ Tuple(rand(D)) .* (extent .- 2Δ)
isvalid_pos = (
!is_overlapping(pos, radius+min_distance, spheres) &&
(through_boundaries || is_inside_boundaries(pos, radius, extent))
)
if isvalid_pos
push!(spheres, Sphere(pos, radius))
break
else
tries += 1
end
end
end
@label packing_complete
@info "$(length(spheres))/$(length(radii)) spheres inserted."
return spheres
end

should call bubblebath! at line 86 after defining the empty spheres vector, reducing code duplication.

function bubblebath( 
     radii::Vector{<:Real}, 
     extent::NTuple{D,Real}; 
     min_distance::Real = 0.0, 
     through_boundaries = false, 
     max_tries = 10000, 
     max_fails = 100 
 )::Vector{Sphere{D}} where D 
     spheres = Sphere{D}[] 
     bubblebath!(spheres, radii, extent;
          min_distance, through_boundaries, max_tries, max_fails
     )
     return spheres
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.