Tech News
← Back to articles

Spherical Cow

read original related products more articles

Spherical Cow

A high volume fraction sphere packing library

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".

Usage

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.

Output

... continue reading