Sunday, January 23, 2011

Fractals!!!!

Now this is physics.We all know we always try to explain nature by simple modelings.To describe natural things we use euclidean objects like Sphere,Circles or Squares.The question here is why? Nature is never so simple(??I have a doubt on the term simple, so do many Scientists ).
Suppose it is your duty to measure the boarder between India and Pakistan.You took a scale of say 20 meter and measured it.You find the length to be X.Now your friend from Pakistan got the same job and whooala he found the length to be Y.Is he cheating? Obviously not .The reason is obviously he is using different scale.It is quite obvious that when keep on decreasing  the length of the scale the total length will increase infinitely because if you keep on decreasing the scale you will  have to take care of every finite details .Is not this like a breaking of curve into self repeating structure? Yes they are fractals.(Btw if it was for a perfect circle or square it would have converge to a certain length)
I don't have any intention to turn this page to a physics book,so I will show you the pictures :)
The basic structure is a Koch Curve .It is funny curve.It is continuous every where and differentiable no where.This how you make it


This was the basic Koch curve. Now I will show you many such curves which actually resembles natural things like mountain,turbulence,galaxy clusters and if we plot on a time scale the evolution too.
Dragon Curve       
   
Cantor Cube





  Is not it amazing all this beautiful structures forms only with some vary basic self repeating structure as in the first graph?The fractals also leads to a confirmation of the fact that nature is Self Organized.I wrote this article because I am too much obsessed with fractals right now.I should tag this as art rather than tagging it as science(:P)

8 comments:

  1. Nice post.....
    Although it could have been much better if you included the mathematics to show that Koch's curve, or any such curve, is "actually" of infinite length in a finite area......

    :P

    ReplyDelete
  2. Well this post has more of mathematics and hardly any physics in it. So I object to the beginning line. Nice post otherwise.

    P.S. Please pay a little more attention to the English for the convenience of the reader.

    ReplyDelete
  3. @Vat What a nick name :P.I will write about infinity sometime then I will surely consider this
    @Avik Yah I paid attention to my grammar but it seems that I can never get reed of silly mistakes.
    Any way Fractals are very much about describing the nature. As I said Koch curve is actually representation of Cost Line.What do you call something that describe nature?

    ReplyDelete
  4. NICE!!

    p.s. who can be concerned with perfection in typing when there's an entire Universe of fractals to explore!...priorities, lol!

    ReplyDelete
  5. To quantumavik, Ummmm this is physics. To Vat, I haven't quite worked it out, but I'm sure you know that log N / log r == fractal D. The spacing is so I could fit the log's on the same line. You will find it interesting that Einstein worked out that the ratio of the true length of a river to the straight line distance of a river is approximately PI. This is actually what I am trying to work out, to show that dimensionality is 3.14, er some logs of a ratio that equals 3.14, idk, I'll get back to you once I understand it. Cheers

    ReplyDelete
  6. Oh, here's some javascript for a koch curve generator.

    var sideSq = window.innerHeight*.95;
    var verts = [0, sideSq*.8, sideSq, sideSq*.8];
    var vertList = [verts];

    function drawCurve(canvas, nverts) {
    var ctx = canvas.getContext("2d");
    ctx.clearRect(0, 0, sideSq, sideSq);
    ctx.beginPath();
    ctx.moveTo(nverts[0], nverts[1]);
    for(var i = 2; i < nverts.length; i++) {
    ctx.lineTo(nverts[i], nverts[++i]);
    }
    ctx.stroke();
    ctx.beginPath();
    ctx.lineWidth = 1;
    }

    function initKoch() {
    var canvas = document.getElementById("canvas");
    canvas.setAttribute("width", sideSq);
    canvas.setAttribute("height", sideSq);
    if(canvas.getContext) {
    drawCurve(canvas, verts);
    }
    }

    function getLines(nverts) {
    var lines = {0: [nverts[0], nverts[1], nverts[2], nverts[3]]};
    if(nverts.length == 4) {
    return lines;
    }
    var lineCount = 1;
    for(var i = 2; i < nverts.length;) {
    lines[lineCount++] = [nverts[i++], nverts[i++], nverts[i++], nverts[i--]];
    }
    return lines;
    }

    function testLines(lines) {
    for(var line in lines) {
    var dx = line[0] - line[2];
    var dy = line[1] - line[3];
    var distance = Math.sqrt(dx*dx+dy*dy);
    if(distance <= 1) return false;
    }
    return true;
    }
    function generateCurve(line, numSides) {
    var dx = line[0] - line[2];
    var dy = line[1] - line[3];
    line.distance = Math.sqrt(dx*dx+dy*dy);
    line.side = line.distance / numSides;
    var offSet = line[0] <= line[2] ? 0 : Math.PI;
    line.direction = Math.atan(-1*((line[3] - line[1])) / (line[2] - line[0])) + offSet;
    var start = 1/2 * (numSides - 1) * line.side;
    var mids = {0:[start*(Math.cos(line.direction))+line[0],start*(Math.sin(-1*line.direction))+line[1]]};
    var interior = (Math.PI/numSides)*(numSides-2);
    var exterior = Math.PI - interior;
    var currAngle = line.direction + interior;
    mids[1] = [line.side*Math.cos(currAngle)+mids[0][0],
    line.side*Math.sin(-1*(currAngle))+mids[0][1]];
    for(var count = 2; count < numSides - 1; count++) {
    currAngle -= exterior;
    mids[count] = [line.side*Math.cos(currAngle)+mids[count-1][0],
    line.side*Math.sin(-1*currAngle)+mids[count-1][1]];
    }
    mids[numSides] = [line.side*Math.cos(line.direction)+mids[0][0],
    line.side*Math.sin(-1*line.direction)+mids[0][1]];
    var temp = [line[0], line[1]];
    for(var i in mids) {
    temp = temp.concat(mids[i]);
    }
    return temp.concat(line[2], line[3]);
    }

    function iterate(numSides) {
    var lines = getLines(verts);
    var canvas = document.getElementById("canvas");
    if(!testLines(lines)) drawCurve(canvas, verts);
    else{
    verts = [];
    for(var line in lines) {
    verts = verts.concat(generateCurve(lines[line], numSides));
    }
    vertList[vertList.length] = verts;
    drawCurve(canvas, verts);
    }
    }

    function pop() {
    if(vertList.length > 1){
    vertList.pop();
    verts = vertList[vertList.length-1];
    }
    var canvas = document.getElementById("canvas");
    drawCurve(canvas, verts);
    }




    ReplyDelete
  7. The retarded validation would not let me publish in its entirety so simply call iterate(3), iterate(4), etc and you will see the polygons jump out. sorry for the inconvenience of not being able to show the true form of the code.

    ReplyDelete