2010年8月6日 星期五

y=x*x_Form ( Processing)




 利用PROCESSING
並使用數學函式
去創造空間造形
這次使用的是最基本的
一元二次方程式
Y=X^2+e
用最基本的數學圖形
創造複雜的形體

Use Processing with Formula to populate
complex geometry.
The Formula we use is the simple formula,
the first volume:
Y=X^2+e.
We would like to use
the simplest graphic to create complex form


Y=X^2+e
即為簡單的拋物線公式
將圖形畫出來後
再進行旋轉

Y=X^2+e
is the simple "PARABOLA."
We draw the PARABOLA and rotate it.

: : 1. PARABOLA_1 
the PARABOLA
rotateX
rotateX and rotateY
 rotateX, rotateY, rotateZ

: : 2. PARABOLA_2
the PARABOLA
rotateZ
rotateZ and rotate Y
with different condant
 rotateZ, rotateY and rotate Z
Y=X^2+(e)
e=200;

: :COMPLEX GEOMETRY:
rotate angle = PI/3


Y=X^3

Program as Followings:

boolean record = false;


import processing.dxf.*;

float n =3; //rotate angle= PI/n;
float c =1; //for loop step;
float a =-50; //starting number
float b =50;//ending number
float d =2;//box length
float s1= 3;//the contant controll the curveture01
float s2 =3;//the contant controll the curveture02
float e1 = 0;//the contant in the first formula:y=x*x-e1 of Y
float e2=4500;//the contant in the first formula: y=x*x-e2 of Z

float e3 = 0;//the contant in the second formula:y=x*x-e3 of Y

float e4= 0;//the contant in the second formula:y=x*x-e4 of Z
//CAHNGABLE VARIABLE



void setup() {
size(700, 700, P3D);
background(0);

noStroke();
//noLoop();
}



void draw() {


if (record == true) {
beginRaw(DXF, "output.dxf"); // Start recording to the file
}//Press "r" to export the DWG file

lights();
background(0);
translate(width/2, height/2, -mouseX/2);
rotateZ(map(mouseY*2, 10, height, 10, PI));

rotateY(map(mouseX*2, 10, width, 10, PI));
//CAMERA

for (float z = 0; z < 2*PI; z+=PI/n) {
rotateX(z);
for (float x = 0; x < 2*PI; x+=PI/n) {
rotateY(x);
for (float y = 0; y < 2*PI; y+=PI/n) {
rotateZ(y);

for (float s = a; s <= b; s+=c) {
if(s>0 && s<=50){
pushMatrix();

translate(s1*s,(s*s-e2)/20-e1,0);
box(s/d);

popMatrix();
}

else{
pushMatrix();


translate(s2*s,-(s*s-e4)/20-e3,0);
box(s/d);


popMatrix();
}
}
}
}
}

if (record == true) {
endRaw();

record = false; // Stop recording to the file
}
}

void keyPressed() {
if (key == 'R'
key == 'r') { // Press R to save the file
record = true;
}
}

沒有留言:

張貼留言