## Uniformly-Distributed Points

Version 1.0.1 (2.41 KB) by
Generate uniformly-sampled points in a 1D, 2D or 3D cartesian or spherical domain with optional pre-existing data via MAXIMIN design

Updated 22 Apr 2022

Calling X = maximin(N, P, varargin) Generates N-uniformly distributed points in P dimensions using the following optional parameter-value pairs:
- 'iterations' Specifies the number of iterations, per cycle.
- 'cycles' Specifies the number of algorithm repetitions.
- 'criterion' Specifies 'cartesian' or 'spherical' sampling.
- 'data' Specifies existing data points in [M, P] form.
- 'initial' Specifies a set of [N, P] points to reiterate.
Examples of the use of this function are the following:
% Generate 40 cartesian equally-spaced points in 3D
x = maximin(40, 3);
plot3(x(:, 1), x(:, 2), x(:, 3), 'o')
view(3)
% Generate 20 equally-spaced points in 2D with pre-existing data
y = rand(10, 2);
x = maximin(20, 2, 'data', y);
figure
hold on
plot(x(:, 1), x(:, 2), 'x')
plot(y(:, 1), y(:, 2), 'o')
% Generate 12 spherical optimally-sampled points in 3D (icosahedron) and create edges
p = maximin(12, 3, 'criterion', 'spherical', 'cycles', 20);
figure
hold on
plot3(p(:, 1), p(:, 2), p(:, 3), 'o', 'Color', 'k')
for i = 1 : 12
d = sum((p(i, :) - p) .^ 2, 2);
d(d == 0) = Inf;
[~, j] = mink(d, 5);
for k = 1 : size(j, 1)
x = [p(i, 1), p(j(k), 1)];
y = [p(i, 2), p(j(k), 2)];
z = [p(i, 3), p(j(k), 3)];
plot3(x, y, z, 'Color', 'k')
end
end
pbaspect([1, 1, 1])
view(3)
% Circular packing problem
p = maximin(10, 2, 'cycles', 20);
d = zeros(10, 1);
for i = 1 : 10
j = sum((p(i, :) - p) .^ 2, 2);
d(i) = min(j(j > 0));
end
d = 0.5 * sqrt(min(d));
a = 2 * pi * (0 : 1 / (1000 - 1) : 1)';
c = d * [cos(a) sin(a)];
figure
hold on
plot(p(:, 1), p(:, 2), 'x', 'Color', 'k')
for i = 1 : 10
plot(c(:, 1) + p(i, 1), c(:, 2) + p(i, 2), 'Color', 'k')
end
xlim([min(p(:, 1) - d), max(p(:, 1) + d)])
ylim([min(p(:, 2) - d), max(p(:, 2) + d)])
pbaspect([1 1 1])

### Cite As

Moreno, M. (2023). Uniformly-Distributed Points (https://www.mathworks.com/matlabcentral/fileexchange/108374-uniformly-distributed-points), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2022a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux