Eretrandre Mathematics Forum

Full Version: n-dimensional pixel approximation of n-sphere
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is quickfur's alter ego (I forgot my password and forgot which of my many email addresses I used to sign up Sad ).

Anyway, I was experimenting with iterated algorithms and stumbled across the following observation, which led me to conjecture that perhaps it's generalizable to n-dimensions, and possibly to any kind of tiling of n-space. However, I'm not clear how to rigorously define my conjecture, so I'm posting here to see what people say.

First, let me explain the "intuitive" motivation behind the following definitions. The idea is that I have a grid of squares, each of which is associated with a scalar value. Initially, only one square has a non-zero positive value, which can be any value but we might as well define it to be 1. You may think of this as a "drop of liquid". At every unit time thereafter, this "liquid" spreads to adjacent squares. Since there are 4 squares surrounding each square, the liquid spreads into 5 equal parts, one on the square it is on, and the others added to the neighbouring squares. We proceed this way, and after N iterations, we look at all squares with a value greater than H, for some positive H. such that H is less than the maximum value of all squares, and greater than some threshold (which I'm not sure how to define). The set of squares included will be a pixelated approximation to a circle---at least, this is what I think, I'm not sure how to prove it.

Anyway, enough hand-waving. Let's be more precise: let represent the value of the square (or n-cube) at coordinate at time . Let be the set of orthogonal unit basis vectors for . Let , where represents the zero vector. Then is defined recursively by:



Each value of represents the next iteration of the "spreading" of the "liquid" over the square (n-cubical) grid of . Let . The claim is that for large values of and certain values of , approximates an n-ball. (Well, I've only actually tested this for n=2, a circular disk.

Unresolved issues:
* I am almost certain that my claim is true for n=2. I wrote a Perl script to actually compute iteratively, and the results indeed do look like concentric circles (if you map each square to a pixel). However, I don't know how to prove this. It must involve taking some limit on N, but I don't know how to formulate it so that the circle doesn't become infinitely large.
* I am less sure of higher dimensions, since I don't have a convenient way to check this for significantly large values of N. (How to visually check this??) So we will need actual mathematical proof here.
* I highly suspect that if the claim is indeed true, then this phenomenon cannot possibly occur only for a square grid; it must occur for all possible tilings of n-space (e.g., triangles, hexagons, with analogous "liquid spreading" functions). But I have no idea how to prove this.

So, can anyone help me prove or refute my conjecture? Smile

I think one very interesting application of this conjecture, if it is true, is that it can be used to approximate the spread of liquid in a grid-based game. If you select a different initial state (not just a single non-zero square), the feedback mechanism of can produce very interesting shapes, which approximate complex shapes, but completely "pixelated" to fit in the grid, and quite easy to implement iteratively.
slowpaw Wrote:First, let me explain the "intuitive" motivation behind the following definitions. The idea is that I have a grid of squares, each of which is associated with a scalar value. Initially, only one square has a non-zero positive value, which can be any value but we might as well define it to be 1. You may think of this as a "drop of liquid". At every unit time thereafter, this "liquid" spreads to adjacent squares. Since there are 4 squares surrounding each square, the liquid spreads into 5 equal parts, one on the square it is on, and the others added to the neighbouring squares. We proceed this way, and after N iterations, we look at all squares with a value greater than H, for some positive H. such that H is less than the maximum value of all squares, and greater than some threshold (which I'm not sure how to define). The set of squares included will be a pixelated approximation to a circle---at least, this is what I think, I'm not sure how to prove it.

Wow thats an interesting idea!
Let me just make some drawings whether I understood you well.

For me that would result in the following sequence

Code:
1.
000
010
000
2.
010
121
010
3.
00100
02320
13631
02320
00100

So if we proceed this, the values form a lozenge.
Indeed the question would be how to choose the threshold, that it becomes close to a circle.
It looks a bit like antialiasing for me, i.e. giving a smooth impression by placing pixels with different brightness along the major contour.

How did you do it in your perl program?
Maybe there is even research literature about algorithms how to antialias a circle. Maybe yours is somehow already listed. I will have a look.
bo198214 Wrote:[...]
Wow thats an interesting idea!
Let me just make some drawings whether I understood you well.

For me that would result in the following sequence

Code:
1.
000
010
000
2.
010
121
010
3.
00100
02320
13631
02320
00100

So if we proceed this, the values form a lozenge.
Indeed the question would be how to choose the threshold, that it becomes close to a circle.
Yes, this is what I meant. Also, perhaps the easiest way to find the threshold would be to look at the value of the squares at the intersection of the lozenge with (for dimension 2). It seems to be pretty consistent that as long as the circle is inscribed within the lozenge, it would correspond with a constant threshold.

Quote:It looks a bit like antialiasing for me, i.e. giving a smooth impression by placing pixels with different brightness along the major contour.
Indeed.

Quote:How did you do it in your perl program?
Quite simple, just create an NxN array, set all elements to 0, set the center element to 1, and iteratively apply the definition of to the entire array. Not the most efficient way to do it, but I just wanted to verify my suspicion based on (very small) hand-calculated computations of .

Quote:Maybe there is even research literature about algorithms how to antialias a circle. Maybe yours is somehow already listed. I will have a look.
I'm curious about how exactly one ends up with a circle in a function that only iterates along the X and Y axes. Smile FYI, dividing by is optional; all it affects is the relative values of the squares. The set of squares with the same threshold still approximate a circle somehow.

I want to find a mathematical formulation of that would allow me to derive the limiting shape, so that I can conclusively prove that it's actually a circle and not some other kind of curve that just happens to look like a circle. And of course, I want to know if this effect also happens for dimensions . So far, this is only a conjecture, and I haven't actually computed in 3 dimensions to see what shape comes out.
Because I am currently a bit low of time I will merely progress slowly (but continuously! The problem looks quite crackable.)

The threshold seems quite essential for me.
And it (the constancy) probably depends on whether we divide by ? (What by the way do you mean by this term? The number of elements of ?)
slowpaw Wrote:Also, perhaps the easiest way to find the threshold would be to look at the value of the squares at the intersection of the lozenge with (for dimension 2). It seems to be pretty consistent that as long as the circle is inscribed within the lozenge, it would correspond with a constant threshold.

So you say (and programmed) to take the threshold as being the first non-zero number on the diagonal? (Unfortunately i didnt see your computation results, which would make it a bit guessier Wink. Can you provide the distribution for say n=20 or so (with colors indicating the values!)?).

If the threshold is clear its not more far to a computation of the limit.
Though we have to determine in what way the approximation shall be considered. I would guess we simply resize the outcome after n steps, by dividing by the length of half the diagonal (which shall be the radius of the near-circle if we chose the threshold as described above). The resulting shape shall approximate the unit-circle for , i.e. the minimum radius of the points of the nth (resized) shape boundary shall converge to 1. Or in other words the minimum radius of the unresized boundary of the shape shall asymptote to .

PS: Btw slowpaw is a really cute name.
Hmm. Actually, I just rewrote the tool I used in C++, and did some further tests, and found that the resulting set is not circular in general, but some kind of higher-order superellipse contained within the lozenge. When the threshold k is set so that the outer extent of the set is near the edges of the lozenge, the shape is clearly non-circular (see attachment).

When the threshold is set near to the maximum at the center of the lozenge, the resulting set is more circle-like, but I'm unsure if it's actually circular.

Open issues:
- Do we get a circular set somewhere between the maximum threshold value and the minimum? I.e., does the shape transition between superelliptical and subelliptical, with the circle in between? Or are they all superelliptical because the function is after all based on a square grid?

PS. Oh, and yes, by I mean the number of members in . It doesn't actually matter, since the relative ratios of the values of the squares are unchanged (this extra factor is simply dividing the entire grid by a constant so it doesn't affect the relative ratios of the values of the squares).
If we only consider a side of the nth lozenge, i.e. the points
then we can conclude that .
So the threshold shall be
slowpaw Wrote:- Do we get a circular set somewhere between the maximum threshold value and the minimum? I.e., does the shape transition between superelliptical and subelliptical, with the circle in between? Or are they all superelliptical because the function is after all based on a square grid?

My guess is that its all superelliptical and becomes closer to a circle for (or increasing threshold) and "is" a circle in (or maximum threshold) Wink
I just found out that the 1-dimensional thing is called
trinomial coefficients.

The trinomial coefficients are defined by
.
(I think the in the article given formula is wrong:
.
)

And there seems to be merely few literature about it.
There exist also closed (but sum-involving) formulas for the trinomial coefficients.
Reference URL's