Skip to content
Snippets Groups Projects
Verified Commit 46185110 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added analysis

parent f2420e5e
Branches
No related tags found
No related merge requests found
......@@ -56,7 +56,11 @@ int main(int argc, char **argv) {
struct timespec time = {0, dt * 1e9};
int num = sqrt(width / 1000.0 / 0.5 / (force / MASS)) / dt;
printf("%d\n", num);
if (debug) {
printf("time position velocity acceleration\n");
} else {
printf("time position\n");
}
gfx_clear(ctxt, COLOR_BLACK);
......@@ -69,7 +73,7 @@ int main(int argc, char **argv) {
if (debug) {
printf("t = %f, pos = %f, vel = %f, acc = %f\n", i * dt, p, vel, acc);
} else {
printf("t = %f, pos = %f\n", i * dt, p);
printf("%f, %f\n", i * dt, p);
}
avg_acc += acc;
}
......
import numpy as np
time_pos = np.genfromtxt("input.txt", delimiter=",")
time = time_pos[:,0]
time_p1 = np.roll(time, -1)
pos = time_pos[:,1]
pos_p1 = np.roll(pos, -1)
# print(pos)
vel = (pos_p1 - pos) / (time_p1 - time)
vel_p1 = np.roll(vel, -1)
# print(vel)
acc = (vel_p1 - vel) / (time_p1 - time)
# print(np.mean(acc[0:len(acc)-2]))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment