How to program a fractal?

后端 未结 14 974
花落未央
花落未央 2020-12-04 05:34

I do not have any experience with programming fractals. Of course I\'ve seen the famous Mandelbrot images and such.

Can you provide me with simple algorithms for fra

14条回答
  •  情歌与酒
    2020-12-04 05:43

    I would start with something simple, like a Koch Snowflake. It's a simple process of taking a line and transforming it, then repeating the process recursively until it looks neat-o.

    Something super simple like taking 2 points (a line) and adding a 3rd point (making a corner), then repeating on each new section that's created.

    fractal(p0, p1){
        Pmid = midpoint(p0,p1) + moved some distance perpendicular to p0 or p1;
        fractal(p0,Pmid);
        fractal(Pmid, p1);
    }
    

提交回复
热议问题