dimanche 7 mars 2021

algorithm to cut segment randomly with constraints

Suppose I have a segment s from 0 to L.

Let n be the number of points in s:

        0                     L
n = 1   |-----------o---------|
n = 2   |----o---------o------|
n = 3   |---o------o----o-----|
n = 4   |--o----o------o---o--|
...............................

The points should be randomly dispersed over s, but the distance between 2 points and between a point and an edge of s (be it 0 or L) must be between 1/2 × L/n and 3/2 × L/n.

How can I distribute the n points in s following these constraints?




Aucun commentaire:

Enregistrer un commentaire