Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2011
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #define PI 3.14159265
  6.  
  7. #define DEG2RAD(x) (x*PI/180)
  8. #define RAD2DEG(x) (x*180/PI)
  9.  
  10. #define dt 0.00001
  11. #define w 15
  12. #define maxBoat 5.0
  13. #define riverDrag 3.0
  14.  
  15. int main(void) {
  16.     float t = 0;
  17.     float x = 0, y = 0;
  18.     float vx = -riverDrag, vy = maxBoat;
  19.     float cx = 0, cy = 0;
  20.     float theta = 0;
  21.    
  22.     for(t = 0;y<w;t+=dt) {     
  23.         x += (vx * dt);
  24.         y += (vy * dt);
  25.        
  26.         theta = -atan((w - y) / x);
  27.         vx = -riverDrag + maxBoat * cos(theta);
  28.         vy = maxBoat * sin(theta);
  29.        
  30.         printf("%f,%f,%f\n", t,x, y);
  31.     }
  32.    
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement