Crates.io | spherical-cow |
lib.rs | spherical-cow |
version | 0.1.4 |
source | src |
created_at | 2018-01-21 17:14:33.314736 |
updated_at | 2021-02-12 09:12:35.818963 |
description | Spherical Cow: High volume fraction sphere packing in arbitrary geometries |
homepage | |
repository | https://github.com/Libbum/spherical-cow |
max_upload_size | |
id | 47682 |
size | 121,510 |
Based on the advancing fronts algorithm outlined in Valera et al., Computational Particle Mechanics 2, 161 (2015).
Milk production at a dairy farm was low, so the farmer wrote to the local university, asking for help from academia. A multidisciplinary team of professors was assembled, headed by a theoretical physicist, and two weeks of intensive on-site investigation took place. The scholars then returned to the university, notebooks crammed with data, where the task of writing the report was left to the team leader. Shortly thereafter the physicist returned to the farm, saying to the farmer, "I have the solution, but it works only in the case of spherical cows in a vacuum".
Complete documentation can be found at docs.rs.
A simple example to get you packing spheres of radii (0.1..0.2) into a container sphere of radius 2.
use spherical_cow::shapes::Sphere;
use rand::distributions::Uniform;
use nalgebra::Point3;
fn main() {
let boundary = Sphere::new(Point3::origin(), 2.0).unwrap();
let mut sizes = Uniform::new(0.1, 0.2);
let spheres = spherical_cow::pack_spheres(boundary, &mut sizes).unwrap();
println!("Number of spheres: {}", spheres.len());
}
More elaborate examples can be found in the examples directory.
True to its name, it is indeed possible to build a spherical cow:
You can run this example yourself from show_in_cow.
The paper which this algorithm comes from gives two examples of real world use cases:
The reason this library was initially written was to optimise the layout of inflatable space habitats which may one day be constructed on the Moon and Mars.
Licensed under the Apache License, Version 2.0 or the MIT license, at your option. These files may not be copied, modified, or distributed except according to those terms.
The wayland-protocols library (released under an MIT license) is used by kiss3d and obj, both of which are only extant in the examples directory of this project (and thus are NOT a part of the library).
Content therein: the file misc/server-decoration.xml
, is Copyright (C) 2015 Martin Gräßlin and licensed under the GNU Lesser General Public Library, version 2.1. You can find a copy of this license at https://www.gnu.org/licenses/lgpl-2.1.en.html