1
$\begingroup$

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

$\endgroup$

3 Answers 3

2
$\begingroup$

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)$.

$\endgroup$
3
  • $\begingroup$ I tried this in geogebra & it worked well for $-1000<t<1000$, though strangely, the shapes edges get sharper & then disappear as $t$ increases beyond $10^5$ (this might just be geogebra; I don't know) so maybe just small $t$ values should be used? $\endgroup$
    – Jam
    Aug 28, 2014 at 11:31
  • $\begingroup$ @EulCan Not quite sure what you mean by the shape getting sharper? If it's an issue, just taking $-1\le t\le1$ will give you half of the circle, and then you could just "turn it around" to get the other half, as I suggested at the end of my answer. $\endgroup$
    – David
    Aug 28, 2014 at 11:46
  • $\begingroup$ I completely agree that $-1<t<1$ & reflecting it is the best course of action. I was attempting to make it a complete circle with large upper & lower limits for $t$ but the circle started looking more like an irregular polygon. By sharper, I meant that the smooth line of the circle became jagged line segments. Quite difficult to express without a picture. $\endgroup$
    – Jam
    Aug 28, 2014 at 11:53
0
$\begingroup$

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...

$\endgroup$
0
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .