Anyone knows if this formula is convertible to escape-time ifs for MB3d or something...

I'm not good at this, plus I'm trying to do a formula by scratch without success. Please help me

http://bernhardhaeussner.de/blog/65_Processing%3A_3D-Koch-Kurve_mit_Sierpinski-DreieckSource code;

fraqTriang trs[]=new fraqTriang[4];

void setup(){

size(640, 480, P3D);

noStroke();

fill(150,150,150,20);

int bigrad=200;

int req=6;

PVector A=new PVector(-bigrad,0,0);

PVector B=new PVector(bigrad/2,0,-173.21);

PVector C=new PVector(bigrad/2,0,173.21);

PVector D=new PVector(0,-bigrad*(sqrt(6)/3),0);

trs[0]=new fraqTriang(A,B,C,req);

trs[1]=new fraqTriang(A,D,B,req);

trs[2]=new fraqTriang(A,C,D,req);

trs[3]=new fraqTriang(B,D,C,req);

}

void draw(){

background(255);

lights();

float winkel=(mouseX/float(width))*TWO_PI;

float xpos=cos(winkel);

float ypos=sin(winkel);

float radius=300.000;

camera(xpos*radius, mouseY, ypos*radius, // eyeX, eyeY, eyeZ

0.0, -50.0, 0.0, // centerX, centerY, centerZ

0.0, -1.0, 0.0); // upX, upY, upZ

for (int i=0;i<trs.length;i++) {

trs[i).display();

}

//saveFrame("frames/koch3d-####.png"); //uncomment to record

}

class fraqTriang{

PVector PointA;

PVector PointB;

PVector PointC;

fraqTriang recTris[]=new fraqTriang[6];

int rec;

float scaling;

fraqTriang(PVector A,PVector B,PVector C, int recursion){

scaling=0.7;

PointA=A;

PointB=B;

PointC=C;

rec=recursion;

applyRecursion ();

}

* void applyRecursion () {*

if (rec!=0) {

PVector PointAB2=PVector.add(PointA,PointB);

PointAB2.div(2);

PVector PointAC2=PVector.add(PointA,PointC);

PointAC2.div(2);

PVector PointBC2=PVector.add(PointB,PointC);

PointBC2.div(2);

PVector PointZ=PVector.add(PointA,PointB);

PointZ.add(PointC);

PointZ.div(3);

PVector PointAB=PVector.sub(PointA,PointB);

PVector PointAC=PVector.sub(PointA,PointC);

PVector PointH=PointAB.cross(PointAC);

PointH.normalize();

PVector PointAAB2=PVector.sub(PointA,PointAB2);

float a=PointAAB2.mag();

float pheight=a*(sqrt(6)/3)*scaling;

PointH.mult(-pheight);

PVector PointZH=PVector.add(PointZ,PointH);

recTris[0]=new fraqTriang(PointA,PointAB2,PointAC2,rec-1);

recTris[1]=new fraqTriang(PointB,PointBC2,PointAB2,rec-1);

recTris[2]=new fraqTriang(PointC,PointAC2,PointBC2,rec-1);

recTris[3]=new fraqTriang(PointZH,PointAC2,PointAB2,rec-1);

recTris[4]=new fraqTriang(PointZH,PointAB2,PointBC2,rec-1);

recTris[5]=new fraqTriang(PointZH,PointBC2,PointAC2,rec-1);

}

} void display () {

if (rec==0) {

beginShape();

vertex(PointA.x, PointA.y ,PointA.z);

vertex(PointB.x, PointB.y ,PointB.z);

vertex(PointC.x, PointC.y ,PointC.z);

endShape(CLOSE);

} else {

for (int i=0; i<recTris.length;i++) {

recTris

*.display();*

}

}

}

}

The interesting part is highlighted...