WTF is this?

The images you see on this blog are output from various Ulam spiral generators I built in Flash, Python and most recently using Arduino. Generally, each dot in an image represents a number with integer 1 at center. In addition to writing algorithms to test each number for primality within a set I have discovered that an infinite number of calculations can be performed to create new designs and animation algorithms. The simplicity and speed of these algorithms make them an ideal fit for embedded systems graphics, scientific, mathematical and artistic explorations.

Wednesday, October 29, 2008

"Classic" 2d Spirals

[The Squirrel]

Well, hey, getting an algorithm to generate the Manhattan skyline with 1 billion red balloons floating overhead like some nightmarish Macy's parade is certainly fun, and a splendid way to waste away a Friday night. But I prefer the basic red-on-black, 2d, no bullshit Sunday-school algorithms. To generate your own squirrel, use this here (Python) code when you test each number:

fooCounter = 1

def testNumber(pInt):
    global fooCounter

    if round( (sqrt(pInt)/pi)+log(fooCounter) )%2 == distillNumber(pInt):
      fooCounter += 1
    return true
  return false

And if you forgot (or still care) what distillNumber does, here it is:

recursive function for boiling down multi-digit ints into single digit ints
def distillNumber(rawNumber):
    distilledNumber = 0

    tmpList = split_len(str(rawNumber))

    for k in range (len(tmpList)):
        distilledNumber = distilledNumber + int(tmpList[k])

    if len(str(distilledNumber))>1:
        distilledNumber = distillNumber(distilledNumber)

    return distilledNumber

def split_len(seq):
    return [seq[i:i+1] for i in range(0, len(seq), 1)]

Let's see what happens when we test for round( (sqrt(pInt)/pi)+fooCounter )%2 == 0...

..or, swap out pi with e round( (sqrt(pInt)/e)+fooCounter )%2 == 0

Now if you kids have been following along at home you know that the goal of all this is to create the ultimate Persian rug design. That's it. I think we've already established said design, but this one isn't too bad. It's quite simply
round( (sqrt(pInt)/e)+ pow(cos(fooCounter),2) )%distillNumber(pInt) == 0 or round( (sqrt(pInt)/e)+ pow(cos(fooCounter),3) )%distillNumber(pInt) == 0
Yes! That's really all there is to it!

Check out those dangly fish-hooky spiral bits. It is the metamorphosis!!!

round( (sqrt(pInt)/e)+ pow(cos(fooCounter),2) )%distillNumber(pInt) == 0 or round( (sqrt(pInt)/pi)+ pow(cos(fooCounter),2) )%distillNumber(pInt) == 0

Now if you're a Persian rug kind of guy, you know, and you're looking to expand beyond the run of the mill patterns that have been standard for thousands of years, look no further. Let's work together and hot rod your loom. You could be doing something like this:

Notice how almost all letters of the Thai alphabet are presented. It's just eerie. อักษรไทย อักษรไทย อักษรไทย

#thai alphabet
round( (sqrt(pInt)/pi)+ pow(sin(fooCounter),2) )%distillNumber(pInt) == 0

Here's another simple method to mess things up good:

def modifyCoordPoint(pNum):
    return pNum + cos(pNum)

You call that from the main algorithm after you've set up your new X/Y positions. Pass in X or Y accordingly.

A lovely variation of this is accomplished by introducing our little circular friend:

def modifyCoordPoint(pNum):
    return pNum + (cos(pNum)*pi)

No comments: