
Superformula_Processing_Flute
6 months ago
/*
3D Superormula
7/12/2007
Aris Bezas
New Version OpenGL-video
7/4/2008
*/
import processing.opengl.*;
import processing.video.*;
MovieMaker mm; // Declare MovieMaker object
float r1=10,r2=10,th=0,f=0;
float m=4,n1=4,n2=3,n3=4,a=1,b=2;
int degrees = 360;
int num = 6;
float[] x = new float[num];
float[] y = new float[num];
float[] z = new float[num];
boolean q = false;boolean w = false;boolean e = false;boolean r = false;boolean t = true;
float angle;
void setup() {
background(255);
size(640,480,OPENGL);
mm = new MovieMaker(this, width, height, "Superformula_Processing.avi",24, MovieMaker.ANIMATION, MovieMaker.HIGH);
}
void draw() {
frameRate(1000);
translate(width/2,height/2);
noFill();
//beginShape();
for(int i=1; i < num; i++) {
r1 = 8*pow(((pow(abs(cos(m*th/4)/a),n2))+(pow(abs(sin(m*th/4)/b),n3))),(-1/n1));
r2 = 8*pow(((pow(abs(cos(m*f/4)/a),n2))+(pow(abs(sin(m*f/4)/b),n3))),(-1/n1));
f = f + .01;
th = th + .005;
x[i] = r1*cos(th)*r2*cos(f);
y[i] = r1*sin(th)*r2*cos(f); //clockwise(change it with - )
z[i] = r2*sin(f);
translate(x[i],y[i],z[i]);
if (q){
line(x[1],x[i],y[1],y[i],z[1],z[i]);}
if (w){
line(0,x[i],0,y[i],0,z[i]);}
if (e){
line(x[1],0,y[1],0,z[1],0);}
fill(random(255)*i,random(255),0);
box(4);
point(x[i],y[i],z[i]);
//curveVertex(x[i],y[i],z[i]);
}
keyboard();
if(f > 15 && f < 16 ) {
f = 0;
m = random(.1,6);
n1 = random(3);
n2 = random(3);
background(255);}
mm.addFrame(); // Add window's pixels to movie
}
void keyPressed() {
if (key == 's') {
mm.finish(); // Finish the movie if space bar is pressed!
}
}
void keyboard() {
if(keyPressed) { // Aktines
if (key == 'q' || key == 'Q') {
q = true;
}}
if(keyPressed) { // Aktines
if (key == 'w' || key == 'W') {
w = true;
}}
if(keyPressed) { // Aktines
if (key == 'e' || key == 'E') {
e = true;
if(keyPressed) { // Aktines
if (key == 'r' || key == 'R') {
r = true;
}}
if(keyPressed) { // Reset Aktines
if (key == 't' || key == 'T') {
q = false;w = false;e = false;r = false;
}}
}}}
3D Superormula
7/12/2007
Aris Bezas
New Version OpenGL-video
7/4/2008
*/
import processing.opengl.*;
import processing.video.*;
MovieMaker mm; // Declare MovieMaker object
float r1=10,r2=10,th=0,f=0;
float m=4,n1=4,n2=3,n3=4,a=1,b=2;
int degrees = 360;
int num = 6;
float[] x = new float[num];
float[] y = new float[num];
float[] z = new float[num];
boolean q = false;boolean w = false;boolean e = false;boolean r = false;boolean t = true;
float angle;
void setup() {
background(255);
size(640,480,OPENGL);
mm = new MovieMaker(this, width, height, "Superformula_Processing.avi",24, MovieMaker.ANIMATION, MovieMaker.HIGH);
}
void draw() {
frameRate(1000);
translate(width/2,height/2);
noFill();
//beginShape();
for(int i=1; i < num; i++) {
r1 = 8*pow(((pow(abs(cos(m*th/4)/a),n2))+(pow(abs(sin(m*th/4)/b),n3))),(-1/n1));
r2 = 8*pow(((pow(abs(cos(m*f/4)/a),n2))+(pow(abs(sin(m*f/4)/b),n3))),(-1/n1));
f = f + .01;
th = th + .005;
x[i] = r1*cos(th)*r2*cos(f);
y[i] = r1*sin(th)*r2*cos(f); //clockwise(change it with - )
z[i] = r2*sin(f);
translate(x[i],y[i],z[i]);
if (q){
line(x[1],x[i],y[1],y[i],z[1],z[i]);}
if (w){
line(0,x[i],0,y[i],0,z[i]);}
if (e){
line(x[1],0,y[1],0,z[1],0);}
fill(random(255)*i,random(255),0);
box(4);
point(x[i],y[i],z[i]);
//curveVertex(x[i],y[i],z[i]);
}
keyboard();
if(f > 15 && f < 16 ) {
f = 0;
m = random(.1,6);
n1 = random(3);
n2 = random(3);
background(255);}
mm.addFrame(); // Add window's pixels to movie
}
void keyPressed() {
if (key == 's') {
mm.finish(); // Finish the movie if space bar is pressed!
}
}
void keyboard() {
if(keyPressed) { // Aktines
if (key == 'q' || key == 'Q') {
q = true;
}}
if(keyPressed) { // Aktines
if (key == 'w' || key == 'W') {
w = true;
}}
if(keyPressed) { // Aktines
if (key == 'e' || key == 'E') {
e = true;
if(keyPressed) { // Aktines
if (key == 'r' || key == 'R') {
r = true;
}}
if(keyPressed) { // Reset Aktines
if (key == 't' || key == 'T') {
q = false;w = false;e = false;r = false;
}}
}}}
- Vimeo: About / Blog / Roadmap / Developers / Community Guidelines / Forums / Toys / Help! / Site Map
- Legal: ©2008 Vimeo, LLC / Terms & Conditions / Privacy Statement




.
305
4
1
0
0
0
Previous Week