Monday, February 16, 2009

3D Binary Patterns

I've been doing multivariable function in math class, so I started thinking about graphing binary in 3D. I've been stacking 3D sets of binary words for ages now, but I'd never done anything more interesting than that. I'm not sure how mathematically rigorous this is, but it is pretty, and that is enough.

First, I drew out a few levels of f(x,y)=x+y on this scale, filling in the z-axis with the binary place value (a cube set on z=1 is in the 2^1=2 place value, so it has a value of 2).

Here is a diagram, rotated so that the pattern is easier to see:

This is not very informative, as all the information below the surface layer is hidden. To remedy this, I switched to considering each place value layer separately, as shown below for all the cubes at z=0 (or the place value 2^0=1)

In order to produce these digitally with my limited graphical abilities, I used a bird's eye view of each place value layer. I wrote a quick program to generate the patterns for my using the formula I worked out a while ago. Here is f(x,y)=x+y at z=1, 2, and 3:

Stripe-y, but not very interesting. 

f(x,y)=x*y, on the other hand, is just plane awesome. Shown here are the first 5 layers:
I don't know if this really qualifies as a fractal, but each decreasing level is a one quarter size approximation of the one that came before. If you try mentally stacking these views, it looks a bit like Cantor's comb, if it was a stool instead of a comb, and a bit more complicated.

The fact that binary produces fractally patterns (fractally is now a word) is not surprising. The most obvious binary pattern, just the numbers 1-31:

(isometric diagrams made with this)

2 comments:

  1. The x*y patterns are awesome, but monochromatic. A suggestion: take the z layers 2 at a time and map to 4 colors instead of black and white. Equivalently, do the x*y in base 4 instead of binary.

    It seems to me that if the layers are similar for binary, they ought to be similar for base 4 (or base 8, etc.). Base 3 or base 5, who knows?

    Anyway, keep up the good work. I've been following you since the fractal teddy bear.

    ReplyDelete
  2. purebasic:
    For x.a=0 To 255
    For y.a=0 To 255

    c.a=x*y
    c=(c&31)
    If c<16
    c=0
    Else
    c=64
    EndIf
    Box(x*4,y*4,4,4,RGB(c,c,c))
    Next y
    Next x

    hope,it helps...

    ReplyDelete