www.flickr.com
Bharath Kishore's items Go to Bharath Kishore's photostream

Thursday, April 23, 2009

Computer and Origami!!

The CP for my radial corrugation.

This has been rendered using the open source "Processing". I came across it just last night and found it really helpful.
This below is the source code for it:

float r,x1,x2,y1,y2,x3,y3,a=0.55,b=0.65;
int i;
float theta,theta1;
void setup(){
size(350,350);
smooth();
r=340.0f;
}
void draw() {
background(255);
translate(width,height);
for(i=0;i<72;i++) {
theta=i*2*3.14/72;
theta1=(i+1)*6.28/72;
x2=r*sin(theta);
y2=r*cos(theta);
x3=r*sin(theta1);
y3=r*cos(theta1);
x1=x2*0.2;
y1=y2*0.2;
stroke(#ffff00);
line(x1,y1,x2,y2);
stroke(0);
line(x1,y1,0.2*x3,0.2*y3);
line(x2,y2,x3,y3);
if(i%4==1) {
stroke(#00ff00);
line(a*x2,a*y2,b*x3,b*y3);
line(x1,y1,a*x2,a*y2);
}
if(i%4==2) {
stroke(#00ff00);
line(b*x2,b*y2,b*x3,b*y3);
line(b*x2,b*y2,x2,y2);
}
if(i%4==3) {
stroke(#00ff00);
line(b*x2,b*y2,a*x3,a*y3);
line(b*x2,b*y2,x2,y2);
}
if(i%4==0) {
stroke(#00ff00);
line(a*x2,a*y2,a*x3,a*y3);
line(x1,y1,a*x2,a*y2);
}
}
}

No comments: