Number of line segments to approximate a circle

1.5k Views Asked by At

This is part of a homework question, so naturally, not looking for a solution. But I have no idea how to approach the problem.

The question is: how many line segments are necessary to approximate a circle 1000 pixels in diameter, such that the approximated circle is no more than one pixel off of the true circle?

Part two is the same question for approximating a spiral $r = \theta : 0 \geq \theta \geq 6\pi$. I am told the solution is non trivial, but still would like to take a crack at it.

3

There are 3 best solutions below

0
On

You will want to use a regular polygon, where the vertices are at distance (at most) $1001$ from the origin and the midpoints of the edges will be at distance (at least) $999$ from the origin. Use trigonometric functions to determine the angle covered by (half of) such an edge, and use that angle to find out how many line segments you need.

0
On

The relationship between a side of regular polygon inscribed in a circle is described as $s=2\sin \frac{\pi}{n}\cdot r$ ($n$ is the number of vertices). The side $s$ of the polygon will be a chord such as that the midpoint of chord is 1 pixel from the circle. Thus, you can find the length of the chord (radius that will go thru midpoint is perpendicular to the chord): $(0.5s)^2=r^2-499^2$. Knowing $s$ you can find $n$ which will be the number of line segments required. Keep in mind that $n$ has to be a natural number.

0
On

I think you need to find the enclosing box of a 1 pixel tall arc:

pic

as for the spiral, you need to use the same formula, just that the radius changes with location, and hence the line segments get longer.

The enclosing angle of the arc is related to the number of segments n.

(arc angle) = 360/n   # in degrees

so to get a 1px tall arc with R=500 px you need

1 = R - R*COS( (angle)/2 )