Compute the set of points (x,y) for a circle of arbitrary radius, with a 1 degree step, without using any trigonometric function.

105 Views Asked by At

Is it possible for a computer program to geometrically construct a approximate circle (pixels have line drawing limitations) without using any trigonometric function?

e.g. taking the unit circle as an example. start at (0,1). next pixel co-ordinate at 1 degree accuracy clockwise would be?

Without using any trigonometric function

3

There are 3 best solutions below

3
On

Use the parametric equations $$x=\frac{1-t^2}{1+t^2}\ ,\quad y=\frac{2t}{1+t^2}$$ for a circle of radius $1$ centred at the origin. You can then easily scale to any radius you like, and translate to be centred at any point you like.

This will not conveniently give you regularly spaced points around the circle - for that I suspect you can't avoid trigonometric functions. But of course you can still plot as many points as you like by taking suitable $t$ values.

There will also be some difficulties near $x=-1$ as this requires the $t$ values to approach $\pm\infty$. However I should think (depending on what programming resources you have available) that you could avoid this by plotting the right half of the circle; then plot the left half by using the same formulae and plotting $(-x,y)$ rather than $(x,y)$.

0
On

Yes, you can do this without using trigonometric functions. As David points out, you can parametrise all points on the unit circle as

$$\left(\frac{1-t^2}{1+t^2}, \frac{2t}{1+t^2}\right)$$

Given a starting point $(x,y)$ on the unit circle, a point $(x',y')$ on the unit circle that is $1^{\circ}$ away from it satisfies $(x,y).(x',y') = \cos(1^{\circ}) \approx 0.9998477$. So if $$(x',y') = \left(\frac{1-t^2}{1+t^2}, \frac{2t}{1+t^2}\right)$$ we get $$\frac{1-t^2}{1+t^2}x + \frac{2t}{1+t^2}y = \cos(1^{\circ})$$

Now, $x$ and $y$ (and $\cos(1^{\circ})$) are known, so we can multiply through by $1+t^2$ to get a quadratic equation in $t$. The two solutions represent the two points $1^{\circ}$either side of $(x,y)$.

I seem to have used a trigonometric function here, but $\cos(1^{\circ})$ is really just a constant...

0
On

Thinking of this iteratively, if you have just plotted the point P (x,y) then the next point you want to plot is P' (cx + sy, cy - sx) where c and s are constants to be determined. (In fact, c and s are cosine and sine of a fixed angle, but we don't have to know that if we are refusing to use trig functions).

c and s must be related by c^2 + s^2 = 1. (This can be proved by requiring that P is the same distance from the origin as P').

If trig functions are banned, then you can choose s by trial and error (using the above equation to determine the corresponding c). For example, if your starting point is (0,1) then after 90 steps you want to reach (1,0). But if the angle is small then the approximation that s = (angle in degrees) / 180 x pi works pretty well. For 1 degree, that gives s = 0.017453, so c = 0.999848 (in line with the previous solver).

With this solution, there's no messing around with parameterisation, it does the whole circle and works with any radius without further modification.