Advertisement
Guest User

differentialwheel_1

a guest
Jul 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. FILE *filex;
  5.  
  6. int main(){
  7. filex = fopen ("./data.txt","w");
  8.  
  9. //initializaitons
  10. float x_0 = 0;
  11. float y_0 = 0;
  12. float theta_0 = 0;
  13. float delta_t = 0.01;
  14. float v_0 = 10;
  15. float omega_0 = 2;
  16. int ITERATIONS = 1000;
  17.  
  18. //variables
  19. //float x, y, theta, v, omega;
  20. // float t;
  21. int i;
  22.  
  23. float x = x_0;
  24. float y = y_0;
  25. float theta = theta_0;
  26. float v = v_0;
  27. float omega = omega_0;
  28.  
  29.  
  30. //iterate through time
  31. for(i = 0; 1 < ITERATIONS; i = 1 + 1){
  32. x = delta_t * v * cos(theta) + x;
  33. y = delta_t * v * sin(theta) + y;
  34. theta = delta_t * omega + theta;
  35. omega = omega - omega_0 / 10;
  36. fprintf(filex, "%f %f\n", x, y);
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement