Last active
February 7, 2017 13:35
-
-
Save FlorianCassayre/b67880380d5a51f6342dcef267f21939 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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