Monday, March 27, 2006

Crackpot Photographs Truman Again


(The title of this post is a line from the emmy award winning futurama episode "Roswell that Ends Well," and it is the headline of a newspaper article that contains a photograph that a conspiracy nut took of president truman. The picture looks like a few lights in the sky, similar to some of the fake ufo pictures of the 20th century.)

ok, so as per the instructions from professor Taylor, I tried to get some renderings of the julia set. I used the formula f(z, c)=+-sqrt(z-c), which actually got a little complicated when i realized that i had to program some complex arithmatic and square roots also! Luckily, Wikipedia exists, and i was able to get a formula for taking the square root of a complex number. Here it is: http://en.wikipedia.org/wiki/Square_root#Square_roots_of_negative_and_complex_numbers
\sqrt{x+iy} = \sqrt{\frac{\left|x+iy\right| + x}{2}} \pm i \sqrt{\frac{\left|x+iy\right| - x}{2}}
(from wikipedia)

also, the magnitude of a complex number |x+iy| is simply sqrt(x^2 + y^2).

In this way, we get another complex number when the square root is taken. Actually, we get two of them, which is how the points are collected.

You start at a point (which i initially did as (0, 0) but that didnt go anywhere) and send it through this process until you have a million points (literally). Then we draw and it looks like the above picture.

The point that i started with for the title rendering was (1+0i) and the c was (1-1.5i).

The point that i started with for the first rendering below was 1+1i, and the c that i used was 0.2+2i.




The last rendering here was with c as 0+0i. I was under the impression that I should get a circle of sorts. I am not sure why it is this squiggly line instead.

Saturday, March 18, 2006

It's a cliche, butter spreads nicely on 3D Mandelbrot


Thats right, you heard me. I am talking about almond-bread, not Benoît Mandelbrot, a French mathematician (wikipedia if you want to find out about him).

Anyway, yummy breakfast plans aside, I worked on doing some plotting of the Mandelbrot set fractal while eating a bagel with cream cheese (the American equivalent to the German mandelbrot and Nutella®).

this is a function f(x, y) which returns a value, which I treat as the height on a heightmap.

(YAY i figured out how to post code!! i will put some code in my earlier posts for those who are interested)

[code]

double mandelize(float x, float y, int max)
{

double x1, y1, xx, xmin, xmax, ymin, ymax = 0.0;

double xperc=x/(float(max));
double yperc=y/(float(max));

int looper = 0;

//this here determines where on the set the view is focused. Right now, this is a zoom on a //region of the set which produced the below renderings
xmin = -0.487f;
ymin = -0.629f;
xmax = -0.486f;
ymax = -0.630f;

x = xmin + xperc*(xmax-xmin);
y = ymin + yperc*(ymax-ymin);
x1=0;
y1=0;
xx=0;
looper = 0;

//this loop keeps track of how long it takes for the function to grow both x and y.
//whenever the distance from the coordinates to the origin becomes larger than 2,
//the loop exits. If this doesnt happen before the counter reaches 200, then the point
//is considered to be an element contained in the mandelbrot set at this resolution
while(looper < xx =" (x1" y1 =" 2" x1 =" xx;" xperc =" looper" val =" (xperc" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/blogger/6686/2189/400/Mandelbrot3DZoom2.jpg" alt="" border="0">

The technique that i used to display the terrain is an iterative detailing technique. I start with a square (this represents the viewing area) which is made of 4 triangles. Then we test the shared vertexes and see if there is a large disparity between the values of nearby points. If the difference is great enough, we "break" the triangle in question in two. This is done everywhere where it is necessary up to a certain maximum depth which is a constant that represents the resolution of the rendering.

Without further discussion, here are some more renderings of a zoomed region of the mandelbrot set (in 3D).

Friday, March 17, 2006

Tie the proverbial knot using math!



I worked on creating a sort of fractal sequence by using two simple transformations: First, I started with a single tetrahedron in space. and I rotate it by a random amount about a random angle. Next, I transform it a small amount outwards to create a long strip of tetrahedrons. This sequence creates the sea urchin look of the thing above.

To make this thing move, I rotate the first tetrahedron in a chain by a tiny amount, then the next, then the next, each time maintaining the coordinate system that the previous rotation created. When done each frame, this causes the tentacles to "curl" inwards, and the severity of the angle and its direction determine how quickly and in which orientation this curling plays out. Here is a series of screens that illustrate the transformation (the coloring is just for effect).


The order of the original structure (even though there is some randomness to how it is shaped) is quickly turned into a chaotic mass of tentacles that curled quickly, eminating grasping tentacles that curled slowly. Thus we have chaos from order!

Monday, March 06, 2006

The "Diet Coke" of random. Just one calorie... not random enough!


Randomness. What is it and who needs it? I think life would be more fun if it made sense! Everything should happen exactly as it is supposed to, no excuses. If I call heads, heads it is.

How droll.

sigh. Now I am bored. I wish things would surprise me for once...

But, even though I am bored, I want to be able to have some sense of what is supposed to happen so I can sleep at night. Therefore, I am going to say that the universe is deterministic. I don't believe in luck, and everything is just falling.

I havent ever read up on quantum mechanics either...

Once we get into the realm of the really really, quite ludicrously small things, it becomes hard to maintain that point of view. One of the most classic examples of a random number is the flip of a coin, and this method of producing a random number relies entirely on quantum mechanics.

See, when the coin is fired up into the air, it rotates around, reaches its pinnacle, then plummets downward for a crazy impact. The moment of that impact is completely unpredictable, and here is why: The deflection of the coin is based on the collision of opposing negative forces of what are essentially electron probability clouds. Because the electrons of the floor and the electrons of the coin are moving at nearly the speed of light, the exact position of the forces that determine the angle and force of deflection will be unique and unpredictable (two important properties of randomness). Furthermore, the coin flip depends on human factors like the velocity and direction of the flip, or possibly sweaty hands, and cannot be accurately described using mathematics.

Now lets consider how we generate a random number on a computer. We use a recursive equation that will spit out a stream of seemingly unrelated numbers when initialized with a seed. The trick is that the seed must be a random number for the sequence to be random*. What we have then is a random number generator that requires a primer of an initial random number to get it rolling. Seems a bit silly, really... if we can already generate a random number, then why would we be trying to generate a random number?

The answer is that there is one pretty decent random number that we always have available, and it is the same mechanism that drives the randomness of the coin flip. The heart of the coin flip was the uniqueness of that particular moment when the coin hits the ground. That freezeframe in time was the random engine. Indeed, that spontaneous instant when you decide to let go of the coin is the force behind the randomness. In computers, it is the exact instant in which the random number generator is initialized that determines the sequence. So the force behind the random number is again, in a way, the spontaneity of your decision to run the program.

In the end, we use our own absurd brains and weird fuzzy logic to break free of the order of a computer to find the chaos that is required to get a truly random number. *Granted, it can be argued that the numbers that computers generate are not random in the same sense as the flip of a coin, but is the flip of a coin random in the same way as rock-paper-scissors?

In rock-paper-scissors, again the random mechanism is slighly different but it returns to the spontaneous instant. There is still a 50% chance of either outcome, but it is based entirely on the whimsical fancy of 2 humans; not on literal quantum collisions but on the interactions of quantum-level software encoded in the brain's neural network.

So what is random? it seems like every random event has its own flavor. I mentioned three examples of "random numbers." Each is determined by a different mechanism, yet each seems valid in different ways, and that is the magic of the random.

I say randomness IS the spontaneousness itself. Its the shifting passions and tides of reality and the urges that make us yell out "rock!" or double click on a program right now instead of now. Maybe that is why a computer will never understand a true random number. They need human beings and our absurd nature to supply that extra kick of random flavor.

mmmmm.... sweet random flavor. Life is good when you don't know what hit you.

Floating like a Flea
I live only where I don't
You cannot find me

-random haiku