Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Last active December 24, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazrdogan/6770472 to your computer and use it in GitHub Desktop.
Save nazrdogan/6770472 to your computer and use it in GitHub Desktop.
Pendulum Processing
// x genlik
float x= (PI/2);
float pos=0;
float pos1=0;
//float a = atan2(mouseY-height/2, mouseX-width/2);
void setup() {
size(800, 800);
}
void draw() {
background(255);
float a = atan2(mouseY-height/2, mouseX-width/2);
if(mousePressed){
translate(width/2, height/2);
//float a = atan2(mouseY-height/2, mouseX-width/2);
rotate(a-x);
pos1=(a-x);
stroke(0);
println(pos1);
//line(-400,0,400,00);
//line(0,-400,0,400);
// rotate(pos);
stroke(0);
line(0, 0, 0, 300);
fill(0, 133, 200);
noStroke();
ellipse(0, 300, 40, 40);
}
else{
translate(width/2, height/2);
// pos = (pos1*cos(millis()/1600.0));
rotate(pos1*cos(millis()/1600.0));
stroke(0);
//line(-400,0,400,00);
//line(0,-400,0,400);
//rotate(pos1*cos(millis()/1600.0));
stroke(0);
line(0, 0, 0, 300);
fill(0, 133, 200);
noStroke();
ellipse(0, 300, 40, 40);
println(pos1);
}
//println(x_pos);
//println(y_pos);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment