Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- FILE *filex;
- int main(){
- filex = fopen ("./data.txt","w");
- //initializaitons
- float x_0 = 0;
- float y_0 = 0;
- float theta_0 = 0;
- float delta_t = 0.01;
- float v_0 = 10;
- float omega_0 = 2;
- int ITERATIONS = 1000;
- //variables
- //float x, y, theta, v, omega;
- // float t;
- int i;
- float x = x_0;
- float y = y_0;
- float theta = theta_0;
- float v = v_0;
- float omega = omega_0;
- //iterate through time
- for(i = 0; 1 < ITERATIONS; i = 1 + 1){
- x = delta_t * v * cos(theta) + x;
- y = delta_t * v * sin(theta) + y;
- theta = delta_t * omega + theta;
- omega = omega - omega_0 / 10;
- fprintf(filex, "%f %f\n", x, y);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement