Uniformal distribution

I have a length L=44 and I have 100 particles (each particle is an object who has its own x and y variables to locate its location in the future).
I want to uniformly distribute the 100 particles in a square of length L
Like this photo >
Color-online-An-example-of-well-sampled-2D-uniformly-distributed-data-points-blue
.

So ten particles per line. Sounds a bit like homework. :wink:

L = 44
x = L/10 * (range(1,10).-0.5)
collect(Iterators.product(x,x))
Output
10×10 Matrix{Tuple{Float64, Float64}}:
 (2.2, 2.2)   (2.2, 6.6)   (2.2, 11.0)   (2.2, 15.4)   …  (2.2, 28.6)   (2.2, 33.0)   (2.2, 37.4)   (2.2, 41.8)
 (6.6, 2.2)   (6.6, 6.6)   (6.6, 11.0)   (6.6, 15.4)      (6.6, 28.6)   (6.6, 33.0)   (6.6, 37.4)   (6.6, 41.8)
 (11.0, 2.2)  (11.0, 6.6)  (11.0, 11.0)  (11.0, 15.4)     (11.0, 28.6)  (11.0, 33.0)  (11.0, 37.4)  (11.0, 41.8)
 (15.4, 2.2)  (15.4, 6.6)  (15.4, 11.0)  (15.4, 15.4)     (15.4, 28.6)  (15.4, 33.0)  (15.4, 37.4)  (15.4, 41.8)
 (19.8, 2.2)  (19.8, 6.6)  (19.8, 11.0)  (19.8, 15.4)     (19.8, 28.6)  (19.8, 33.0)  (19.8, 37.4)  (19.8, 41.8)
 (24.2, 2.2)  (24.2, 6.6)  (24.2, 11.0)  (24.2, 15.4)  …  (24.2, 28.6)  (24.2, 33.0)  (24.2, 37.4)  (24.2, 41.8)
 (28.6, 2.2)  (28.6, 6.6)  (28.6, 11.0)  (28.6, 15.4)     (28.6, 28.6)  (28.6, 33.0)  (28.6, 37.4)  (28.6, 41.8)
 (33.0, 2.2)  (33.0, 6.6)  (33.0, 11.0)  (33.0, 15.4)     (33.0, 28.6)  (33.0, 33.0)  (33.0, 37.4)  (33.0, 41.8)
 (37.4, 2.2)  (37.4, 6.6)  (37.4, 11.0)  (37.4, 15.4)     (37.4, 28.6)  (37.4, 33.0)  (37.4, 37.4)  (37.4, 41.8)
 (41.8, 2.2)  (41.8, 6.6)  (41.8, 11.0)  (41.8, 15.4)     (41.8, 28.6)  (41.8, 33.0)  (41.8, 37.4)  (41.8, 41.8)
2 Likes

Or simply, a tuple:

julia> L = 44;

julia> tuple.(0.5L/10:L/10:L, (0.5L/10:L/10:L)')
10×10 Matrix{Tuple{Float64, Float64}}:
 (2.2, 2.2)   (2.2, 6.6)   (2.2, 11.0)   …  (2.2, 37.4)   (2.2, 41.8)
 (6.6, 2.2)   (6.6, 6.6)   (6.6, 11.0)      (6.6, 37.4)   (6.6, 41.8)
 (11.0, 2.2)  (11.0, 6.6)  (11.0, 11.0)     (11.0, 37.4)  (11.0, 41.8)
 (15.4, 2.2)  (15.4, 6.6)  (15.4, 11.0)     (15.4, 37.4)  (15.4, 41.8)
 (19.8, 2.2)  (19.8, 6.6)  (19.8, 11.0)     (19.8, 37.4)  (19.8, 41.8)
 (24.2, 2.2)  (24.2, 6.6)  (24.2, 11.0)  …  (24.2, 37.4)  (24.2, 41.8)
 (28.6, 2.2)  (28.6, 6.6)  (28.6, 11.0)     (28.6, 37.4)  (28.6, 41.8)
 (33.0, 2.2)  (33.0, 6.6)  (33.0, 11.0)     (33.0, 37.4)  (33.0, 41.8)
 (37.4, 2.2)  (37.4, 6.6)  (37.4, 11.0)     (37.4, 37.4)  (37.4, 41.8)
 (41.8, 2.2)  (41.8, 6.6)  (41.8, 11.0)     (41.8, 37.4)  (41.8, 41.8)
1 Like