3
$\begingroup$

I am sorry if this sounds a bit convoluted but here goes.

I have written a program that traces a symmetric approximation of a square, my function does not use sine, cosine,or any trigonometric functions, angles or pi... At least not explicitly. It takes two arguments - i,j which are indexes of the center point of the circle, and a variable r denoting the radius. What it does is use complex vector spaces to enable parallelization of the process of tracing the curve directly into the relevant cells that indicate the curve around the i,j center point.

The program works very well, tracing a perfect circle(the circle is not centered properly because my matrix had an even number of rows and columns- but the circle itself is perfectly symmetric):

enter image description here

But there was something that made me curious and I failed to figure it out, I inserted into the program a part which saves the real distance of every cell on the circumference from the radius(I am approximating a circle with squares here), just out of curiousity to see how the plot looks. when I plotted it, here is what I got ( this is a 1D plot):

enter image description here

My questions:

  1. Why are there various elliptic curves inside this 1D plot of real valued distances? I calculated the mean of the distances from each point on the curve to the radius, It seemed oddly close to 0.676211.... which is very close to e/4. When I tried plotting with a larger radius, it never got over the value of e/4, and it seemed to be converging on it. why?

  2. The point with the maximum distance between it and the radius, was 1.55... which is converging on pi/2 but from above - meaning the value is usually above pi/2, but again - as r grows it also seems to converge on it - although not asymptotically.I guess that makes sense somehow because the radius marks the circumference, but still. why pi/2?

  3. Not a question but just a note, the program terminates after exactly 8r points have been traced. the area of the circle seems to follow the following polynomial equation 2(r - 1)^2 +2(r - 1) + 1.

Just to finish - plots of distances from the radius when the length of the circle radius = 459, and length of the circle radius = 4799 (just random values) if anyone knows any method of understanding what the hell is going here I will be very intrested: enter image description here enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ You meant to write "symmetric approximation of a circle", right? For a "cell on the circumference", what do you mean by its "distance from the radius"? Is it supposed to be the shortest distance between the circle and the center of that cell? It'll be difficult to answer your question without knowing where the cells are placed (relative to the circle) and how they are indexed. $\endgroup$ – r.e.s. Jul 2 '20 at 22:57
  • $\begingroup$ @r.e.s. thank you for the reply. Yes I meant to write a symmetric approximation of a circle. When I say a "distance of a cell on the circumference from the radius", one could think of this as the error of approximation, how far are the values of integer indexes of the cells(this is a regular matrix) - from the outer edge of the radius, this distance is not measured from the middle of a cell, but from its outer edge which is closest to the radius on the plane. So how far are the edges of the discrete squares from the continuous circumference line of the circle - which is indicated by the radius $\endgroup$ – dvd280 Jul 3 '20 at 6:36
  • $\begingroup$ Understanding your plots requires knowing more about how recordi is determined from Index. In your first picture, are the small yellow squares simply indexed in a clockwise (or counterclockwise) order around the circle? If Index$=i$ identifies the $i$th small yellow square, what is the actual formula for recordi for that square (in terms of the radius of the circle and the size & location of that square)? $\endgroup$ – r.e.s. Jul 3 '20 at 14:15
  • $\begingroup$ @r.e.s. the yellow square is identified by two coordinates i,j and in order to compute its record value, you can get it by doing: abs ( sqrt(i**2 + j**2) - r ) $\endgroup$ – dvd280 Jul 3 '20 at 15:30
  • $\begingroup$ That gives record as a function of $(i,j)$ and $r$, but for the plot we need to know record as a function of Index; so, how exactly is $(i,j)$ determined from Index? $\endgroup$ – r.e.s. Jul 3 '20 at 15:38
2
$\begingroup$

I think the following is adequate evidence that your plots are actually showing hyperbolas that arise when several cells happen to fall in a straight line. Lacking exact details of your algorithm, I wrote a program to find all the $1\times 1$ open square lattice cells in the plane that overlap a circle of given radius. (This number appears to be asymptotic to $8r$ as $r\to\infty,$ consistent with what you found.) For each cell with corner-coordinates $(i,j),(i,j+1),(i+1,j),(i+1,j+1)$, I then computed the distance between the circle and the point $(i,j).$

As an example with $r=459$, the following plot on the left shows distance vs cell index for the first $2000$ cells (there being exactly $3660$ cells overlapping the circle), the cells being indexed in counter-clockwise sequence around the circle from angle $0$ back to $2\pi:$

plots of distance vs cell index

The plot on the right is the result of re-ordering the cells in the manner you have done (as you explained in comments), so that the first four cells are the ones at angles $0,\pi/2,\pi,3\pi/2$, the next four are the next ones counter-clockwise after those respective locations, and so on around the circle. This "interleaving" is what causes various hyperbolas to get matched up with inverted hyperbolas, giving the appearance of closed curves.

Why hyperbolas? It's a consequence of the alignment of several cells that overlap the circle. For example, letting $d_n$ be the distance between the circle and the corner of the $n$th such cell (in counter-clockwise order), I find $d_n = r - \sqrt{(r-1)^2 + n^2}$, or $(d_n-r)^2 - n^2 = (r-1)^2,$ which is the equation of a hyperbola.

$\endgroup$
9
  • $\begingroup$ wow, very interesting, and how can we explain the aparent convergence of the mean value of the distances into e/4, and the maximum value of the vector seeming to be non asymtotically converging on pi/2? $\endgroup$ – dvd280 Jul 4 '20 at 7:00
  • $\begingroup$ I will just add, the number of cells on the circumference is not converging on 8*r, it is 8*r not asymtotically but completly. This I say because exactly 8*r iteration are needed to trace a circle this way. $\endgroup$ – dvd280 Jul 4 '20 at 7:13
  • 1
    $\begingroup$ @dvd280 The convergence questions are interesting. In some cases the limits are clear; e.g. the distances generated by my algorithm have a maximum of $\sqrt{2}=1.414...$ (just the diagonal length of a unit square). I have yet to check the avg value, etc. Now, about the $8r$ ... yes, for your algorithm, $8r$ is the actual number of squares, whereas for my algorithm $8r$ is only an asymptotic value (e.g. for $r=459$, the number of squares is exactly $3662\approx 7.978r.$ (Is there somewhere online where you explain your algorithm?) $\endgroup$ – r.e.s. Jul 4 '20 at 12:31
  • $\begingroup$ I am still working on tweaking and writing a rigorous proof for it- which I will publish through my university, but i think i know why your top limit does not land exactly where it should, and I would guess it is because the function you use to generate the circle is not perfectly symmetric , it computes the circle does not address symmetry locally, which I think is crucial for it to converge to 8*r. $\endgroup$ – dvd280 Jul 4 '20 at 12:41
  • $\begingroup$ @dvd280 No, my algorithm just finds the unit-square lattice cells that overlap the circle -- it'll clearly get different squares than yours (which uses some cells that don't even touch the circle!) -- and it's easy to see that mine does have the exact upper bound of $\sqrt{2}$. Also, it's clear that for my algorithm, $8r$ is only an asymptotic result, as there are clearly fewer than that number of overlap squares when $r$ is small. (Correction: For $r=459$, the number of overlap squares is $3660,$ not $3662.$) $\endgroup$ – r.e.s. Jul 4 '20 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.