Compute number of regular polgy sides to approximate circle to defined precision I am trying to approximate a circle with a regular polygon for a drawing program.
I would like to compute how many sides are needed for a regular polygon to approximate a circle of radius $R$ such that at the point where the regular polygon is furthest from the true circle it is less than some specified tolerance $D$.

It seems like there should be a clear solution to this, but I have no idea where to begin.
Thanks for taking a look at my question!
 A: The distance in question is
$$D = R\left(1-\cos\left(\frac\pi n\right)\right),$$
as you can check from this answer, for example.
Combining that with $D \le \epsilon$ and doing a bit of algebra, we get
$$n \ge \frac\pi{\arccos\left(1-\frac\epsilon R\right)}.$$
A: Considering a circle with radius $R > 0$ and center the origin, if a vertex of a $n$-sided regular polygon inscribed in it is $\left(R,\,0\right)$, the next one in an anticlockwise direction has coordinates $\left(R\,\cos\left(\frac{2\,\pi}{n}\right),\,R\,\sin\left(\frac{2\,\pi}{n}\right)\right)$.
The required distance is equal to the difference between the radius of the circle and the distance of the midpoint between the two vertices considered from the origin:
$$
D = R\left(1 - \cos\left(\frac{\pi}{n}\right)\right)
$$
for which, once a tolerance $\delta = \kappa\,R$ with $0 < \kappa \le \frac{1}{2}$ is fixed, we get:
$$
D \le \delta
\quad \quad \quad
\Leftrightarrow
\quad \quad \quad
n \ge \frac{\pi}{\arccos\left(1-\kappa\right)}
$$
i.e.
$$
n_{min} = \text{ceiling}\left(\frac{\pi}{\arccos\left(1-\kappa\right)}\right).
$$
On the other hand, this expression can be simplified with the first term of the Maclaurin series:
$$
n_{min} = \text{ceiling}\left(\frac{\pi}{\sqrt{2\,\kappa}}\right)
$$
which at most overestimates by one side compared to the exact one. That's all. ^_^
