Using Prime Numbers to Generate Backgrounds
bpeh123 pointed out an article about generating organically tiled backgrounds inspired by the life cycle of cicadas. The trick is to overlay multiple background tiles with prime widths thus generating a series that does not repeat for a sufficiently long period. This introduces a seeming irregularity and makes the background appear much more natural.
...NEEEEEEieieiirrrnngngne eEEEEEEEEEEee eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeernrng!
Do daemons dream of electric sleep()?
Why can I only check Post Anonymously when I post a new comment but not a reply? Also, it would be kinda cool if I could click on fucking links again without having to triple right click and then open in a new window.
They can't even quote an article they link to properly ."
Their article: "that is,1, 2, 3, 5, 7, 11, 13, 17, 19, 23, and so on"
Wikipedia: "2, 3, 5, 7, 11, 13. .
Cool. I've looking at automatically generating stuff for games recently. Obviously, this works for authentic-looking backgrounds, but my friends and I were working on a project that involved automating critter generation using classic predator-prey models. One big worry was the farming-to-death of critters that are part of an ecosystem. This idea might be useful for much more nicely randomized or randomized-seeming mob population/spawning.
No OS on the planet can protect itself from a user with the admin password. - Yvan256
How about: Designer discovers new way to use special properties of primes to create more realistic tiled background images.
C'mon, the results are actually pretty cool.
You missed the important thing ... designer creates huge frickin' lego army using a small number of images and some pretty smart use of CSS.
An army, but make out of lego. Put lasers on them and see who takes over the world. :-P
Lost at C:>. Found at C.
Yes, some characters do. The Slashdot Janitors have decreed that only 7-bit ASCII can be used on the site and everything else should be presented in as broken a way as possible.
Because obviously, we're geeks so we're all using 30-year-old ADM3A terminals.
It doesn't matter if cicadas are important to birds or any other predator. Predators are important to cicadas.
In any case, he's talking about making things look random enough for casual observation. He's not talking about some sort of advanced encryption algorithm. We know we can appeal to advance math and chaos theory for truly random. But this is just web design. If someone actually cracks the pattern, it isn't the end of the world.
Democracy Now! - your daily, uncensored, corporate-free
Just because you do not understand something does not make it wrong. Birds haven't "evolved" a boom/bust cycle, that's not how that works. It's the standard predator/prey boom/bust cycle. Birds don't spend vast periods of time underground, you know. Curtains are natural, "natural" here taking the meaning of "organic" rather than "patterned.
Please, don't be one of those guys who tries to prove how smart they are by attempting to find fault with the article. It does not make you look as smart as you think. The fact that you hurt your brain trying to comprehend something the rest of us had no trouble understanding actually makes you look pretty dumb.
- None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
Not only did I learn interesting information about the insects I hate the most (and believe me, if I could, I would destroy every last one of the annoying bugs!) but I also learned that you can have multiple images for backgrounds in CSS and have them lay atop one another. (None of the books or software ever seemed to suggest that it was even possible!)
While the idea is pretty ingenious, if I had known you could specify more than one image for backgrounds, I would have figured this one out on my own -- I have been overlaying images and background images inside of DIVs for a while to get some really nice effects. But now, to be able to lay one atop the another in the same block? AWESOME.
And yes, at the article says, inferior browsers cannot handle this -- I tried it on IE8 to see what would happen and... yeah... it hung.
Now, next time Iran fakes out a missile launch test and claims it has tested some 53 rockets and shows pictures, it is going to be impossible to detect the cut/paste jet plumes.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
One is itself, so it only has one factor. Really.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
How about: Designer comes up with interesting, relevant use of math that all the Math geeks who have been running the WWW for 20 years didn't think of on their own.
Subtitle: Bitter math nazis harp on his confusion about 1 being a prime.
Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
Primes have, by definition, exactly two factors. 1 has only one: 1.
Of course, you could define them differently, and a hundred years ago, 1 indeed was considered a prime. But the definition excluding 1 has turned out to be much more useful (because almost everywhere you use primes you'd have to add "except 1" otherwise), therefore 1 is no longer considered prime.
The Tao of math: The numbers you can count are not the real numbers.
The point isn't randomness, the point is unwanted harmonics in pseudo-random patterns. These unwanted harmonics cause regular repetitions in the pattern that make it seem predictable and non-random. Prime numbers are the basis by which a simple PRNG (pseudo-random number generator) generates seemingly-random data that doesn't repeat in any predictable manner. By overlapping two or more sequences with prime lengths, the length of the harmonic is maximized. That means the sequence goes longer before repeating itself. Sequences with non-prime lengths short-circuit the cycle.
For instance, overlapping three sequences of length 7, 11, and 13 forms the following pattern:
http://tinyurl.com/3wserj7
At a glance, the pattern looks fairly random and non-repeating; however if you look more closely you see that the vertical bands of color are repeating very regularly within the pattern. But, since their periodicity is prime, the pattern as a whole doesn't appear to repeat itself. Using alpha and larger 2-dimensional tiles you can create even more complex and random-seeming patterns.
The life cycle of cicadas is similar in that the overlapping cycles tend to cause a seemingly-random pattern of years with lots of cicadas and few cicadas, such that the life cycle of their predators is less likely to hit a bunch of good cicada years in a row and seriously harm the population of them.
A lot of proofs in recursion / computability theory actually depend on the fact that one is not a prime number. More specifically, they depend on the property of numbers that is called unique factorisation into primes, a very important theorem in mathematics that is a corner stone for many proofs in a variety of mathematical disciplines. If you count 1 as a prime number, this theorem does not hold, with all the consequences that you might suspect it entails.
Just sayin'. 1 is not a prime number.
This is in fact true.
The best reason for leaving one out of the prime number set is because it enables you to state the prime number theorem more succinctly:
Every integer n>1 has a unique factorisation as a product of primes (Prime factorisation)
If one was prime, then the factorisation would not be unique. For example 6=2.3, but if 1 was an allowed prime then 6=1.2.3=1.1.2.3=1.1.1.2.3= .... 1^n .2.3. So it's preferred to leave one out.
There are other reasons, but the prime number theorem is perhaps the best one.
May the Maths Be with you!
This is very much not like Perlin noise, because Perlin noise uses octaves (doubles in frequency). Octaves are harmonic with each other by definition. This uses primes, specifically to cause the harmonics to occur as far apart as possible. Using octaves in this way would cause very repetitive-seeming patterns because the maximum size of your pattern would be defined as the size of your largest sequence, and all of the shorter sequences would tile into it in a neat checkerboard.
Perlin noise requires infinite sequences of pseudo-random numbers and would be extremely ill-suited to using short repeating sequences. This is specifically designed to minimize the length of the sequences you use without causing obvious repetitions in the pattern by using sequences of prime length (since your "sequence" is a PNG, if it's too large it takes a long time to load).
Cool, but aren't we all supposed to be using fractals to generate realistic-looking virtual worlds and such by now? I mean, that's what I thought when I read that Scientific American article back in the 80s, and wrote a C program that ran for two weeks on my Compaq to create a picture of a Mandelbrot set. What was really funny was that the Compaq screen was grey scale...
Great men are almost always bad men--Lord Acton's Corollary
You somehow simultaneously displayed a lack of understanding for the mechanisms of evolution (mutation and natural selection), and obliviousness to the point of the mathematics being discussed: using prime numbers to reduce periodicty of a given set of cycles.
Also, your third and fourth paragraphs display utter ignorance of biology.
Why are you even here? This article was very well articulated, and more important, useful, unlike your reply.
FanFictionRecs.net
No, you are simply wrong, as I quite clearly demonstrated, which is why you were modded down and I was modded up. So let me try to explain it in the very simple terms you need.
Again, birds did not evolve a boom/bust cycle. They can not pick it through evolution, it is not up to them, it is up to their predators and food sources. As the article clearly explains, a prime number cycle for cicadas ensures that only ONE predator boom/bust cycle will match up with theirs, and natural predator/prey cycles are not ever that long. Here, all you demonstrate is a complete lack of understanding of evolution and ecology.
You also have quite clearly either not read, or not understood the article. More importantly, you appear to not have even looked at the pictures. By overlapping patterns in prime cycles, a complex pattern is built up that does not appear repetitive to the eye. It was clearly demonstrated in the pictures, in case you are illiterate.
Curtains ARE nature, everything is. Hanging curtains create a natural, complex pattern of folds. A standard repeating background does not have those same complex patterns.
When you say "random things look random because they are random." you clearly demonstrate again that you have not read the article. Are curtains random? If you generated a 'random' curtain texture and tiled it, would it still appear random? No! It would not be seamless. But if you generated the tile using prime numbers, you could tile it and not see obvious seams.
As I explained, they are not using prime numbers to mimic randomness, they are using them to create tiles that appear seamless. You total fucking idiot.
When you claim "Fifth, nature does cyclical rather handily; not everything need be random to look natural." you AGAIN clearly demonstrate your total lack of comprehension about the article. They are not trying to create "random" you microencephalic retard, they trying to create background patterns that can be repeated across a page without appearing to be repeating tiles. You utter cretin.
Now fuck off and let the smart people talk. I'm done with you, you're dismissed from class.
- None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
Well, the images do have to be an integer number of pixels wide, but if the ratio between lengths approximated an irrational number you would expect long periods. Even relatively prime numbers would work. Tiles of length 7, 15, and 16 won't repeat for 1,680 pixels. Basically, if you want to create a nice, non-repetitive pattern of overlayed tiles, make certain that the smallest common multiple for all of the tile sizes is larger than your expected screen width.
Penrose tiles are cooler. They are aperiodic, the tiling never repeats, instead of just having a long period.
Not a sentence!