# Generating Equidistant Points on Unit Disk

Recently I needed an algorithm to generate equidistant points inside the unit disk with some of them placed on the boundary (circle). To my surprise, quick search didn’t reveal any simple method for this. Below is obvious solution & code, hopefully it will save some time for others.

MATLAB code:

```function [x, y, Nb, Np] = eqdisk(Nr)
%EQDISK Generates equidistant points inside the unit disk.
%   Nr  [in]  - number of radial circles
%   x,y [out] - coordinates of generated points
%   Np  [out] - total number of generated points
%   Nb  [out] - points on boundary (on r = 1 circle)

dR = 1/Nr;

x(1) = 0;
y(1) = 0;

k = 1;
for r = dR:dR:1

n = round(pi/asin(1/(2*k)));

theta = linspace(0, 2*pi, n+1)';
x = [x; r.*cos(theta(1:n))];
y = [y; r.*sin(theta(1:n))];

k = k+1;
end;

Nb = n;
Np = size(x,1);
end
```

Algorithm is based on the idea of placing the points on concentric circles with (near-) equal arc length between them. Here is some examples:      Note the “equilibrium” case, when we have the same number of points on boundary and inside the disk, Nr=3 (19/19).     (11 votes, average: 4.91) Loading...

### One Comment

1. Posted August 11, 2018 at 8:40 am | #

Tammes and Thomson problems can be considered as an extension for non-Platonic cases. For instance, see Math Overflow: Distributing points evenly on a sphere . Sadly, general solutions to these problems are not trivial.