Skip to content

Instantly share code, notes, and snippets.

@FlorianCassayre
Last active February 7, 2017 13:35
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 FlorianCassayre/b67880380d5a51f6342dcef267f21939 to your computer and use it in GitHub Desktop.
Save FlorianCassayre/b67880380d5a51f6342dcef267f21939 to your computer and use it in GitHub Desktop.
final float g = 0.5, m1 = 1, l1 = 100;
final float i = m1 * l1 * l1 / 3; // m*L^2/3
float a = 0, v = 0.01, x = -PI / 2 + 0.1;
void setup()
{
size(500, 500);
}
void draw()
{
// Draw
background(255);
line(width / 2, height / 2, width / 2 + l1 * cos(x), height / 2 + l1 * sin(x));
ellipse(width / 2, height / 2, 5, 5);
// Calculate
a = l1 / 2 * g * sin(x + PI / 2) / i;
v += a;
x += v;
println("a=" + a + " v=" + v + " x=" + x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment