Crate decluster

Source
Expand description

Performs a random search for a viable set of points where each point is separated from all other points by at least the specified minimum distance. It works on an inital set of randomised 2D points finding and replacing clusters with new random points until it settles on the viable declustered set - if that is acheivable given the number of points and, the size of the window and minimum allowable distance.

§Basic Usage

use decluster::Canvas;

pub fn main() {
    let point_count = 500;
    let min_distance = 66.0;

    Canvas::new(point_count, min_distance).show();
}

§Examples

For more notes and a working example please see the decluster_demo example that accompanies this lib. The source for the demo is listed under the examples directory on GitHub.

To compile and run the example use:

> cargo run --example decluster_demo --release

Once you get it running then have play with the point_count and min_distance parameters to find the interesting tipping points where viable sets exist but are increasingly hard to find.

For example with a screen size of [2560, 1440] and a point count of 500 the balance point exists when the minimum distance lies between 65 and 70.

With these numbers there exists a limited set of viable distributions that manage to fit all the points whilst maintaining the specified minimum distance. As a result you will see the algorithm take its time before eventually settling on a viable distribution. Increasing the minimum distance just a little from here will increase the difficulty further until eventually no viable solutions exist and the algorithm will cycle.

Modules§

  • decluster 🔒
    An iterative algorithm that searches for a set of points where each point is separated from all others by at least the minimum specified distance.
  • point 🔒
    A 2D point representing a location in a results space.

Structs§

  • The drawing surface and piston window used to display the set of points.