fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <math.h>
  4.  
  5. #define CENTER 127
  6.  
  7. void rotate(int *x, int *y, float a){
  8. int tx = *x - CENTER;
  9. int ty = *y - CENTER;
  10. tx = tx * cos(a) - ty * sin(a);
  11. ty = tx * sin(a) + ty * cos(a);
  12. ty += CENTER;
  13. tx += CENTER;
  14. *x=tx; *y = ty;
  15. }
  16.  
  17. int x, y;
  18. int x0 = 127;
  19. int y0 = 127;
  20. float r;
  21.  
  22. int main(void) {
  23. // your code goes here
  24. for(uint8_t i = 0; i<60; i++){
  25. x = 127; y = 200;
  26. rotate(&x, &y, i * 3.1415 * 2 / 60);
  27. rotate(&x0, &y0, i * 3.1415 * 2 / 60);
  28. r = sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y));
  29. printf("i=%d, x0=%d, y0=%d, x=%d, y=%d, r=%f\n", i,x0, y0, x, y, r);
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5532KB
stdin
Standard input is empty
stdout
i=0, x0=127, y0=127, x=127, y=200, r=73.000000
i=1, x0=127, y0=127, x=120, y=198, r=71.344238
i=2, x0=127, y0=127, x=112, y=195, r=69.634758
i=3, x0=127, y0=127, x=105, y=189, r=65.787537
i=4, x0=127, y0=127, x=98, y=181, r=61.294373
i=5, x0=127, y0=127, x=91, y=172, r=57.628117
i=6, x0=127, y0=127, x=85, y=161, r=54.037025
i=7, x0=127, y0=127, x=79, y=149, r=52.801514
i=8, x0=127, y0=127, x=73, y=135, r=54.589375
i=9, x0=127, y0=127, x=68, y=123, r=59.135437
i=10, x0=127, y0=127, x=64, y=109, r=65.520988
i=11, x0=127, y0=127, x=61, y=97, r=72.498276
i=12, x0=127, y0=127, x=58, y=84, r=81.301903
i=13, x0=127, y0=127, x=56, y=73, r=89.202019
i=14, x0=127, y0=127, x=55, y=64, r=95.671310
i=15, x0=127, y0=127, x=55, y=56, r=101.118744
i=16, x0=127, y0=127, x=55, y=48, r=106.887794
i=17, x0=127, y0=127, x=56, y=43, r=109.986366
i=18, x0=127, y0=127, x=58, y=39, r=111.825760
i=19, x0=127, y0=127, x=61, y=38, r=110.801628
i=20, x0=127, y0=127, x=64, y=36, r=110.679718
i=21, x0=127, y0=127, x=68, y=37, r=107.615051
i=22, x0=127, y0=127, x=73, y=39, r=103.247276
i=23, x0=127, y0=127, x=79, y=41, r=98.488579
i=24, x0=127, y0=127, x=85, y=44, r=93.021500
i=25, x0=127, y0=127, x=91, y=46, r=88.639717
i=26, x0=127, y0=127, x=98, y=49, r=83.216583
i=27, x0=127, y0=127, x=105, y=51, r=79.120163
i=28, x0=127, y0=127, x=112, y=53, r=75.504967
i=29, x0=127, y0=127, x=120, y=54, r=73.334846
i=30, x0=127, y0=127, x=127, y=55, r=72.000000
i=31, x0=127, y0=127, x=134, y=54, r=73.334846
i=32, x0=127, y0=127, x=142, y=53, r=75.504967
i=33, x0=127, y0=127, x=149, y=51, r=79.120163
i=34, x0=127, y0=127, x=156, y=49, r=83.216583
i=35, x0=127, y0=127, x=163, y=46, r=88.639717
i=36, x0=127, y0=127, x=169, y=44, r=93.021500
i=37, x0=127, y0=127, x=175, y=41, r=98.488579
i=38, x0=127, y0=127, x=181, y=39, r=103.247276
i=39, x0=127, y0=127, x=186, y=37, r=107.615051
i=40, x0=127, y0=127, x=190, y=36, r=110.679718
i=41, x0=127, y0=127, x=193, y=38, r=110.801628
i=42, x0=127, y0=127, x=196, y=39, r=111.825760
i=43, x0=127, y0=127, x=198, y=43, r=109.986366
i=44, x0=127, y0=127, x=199, y=48, r=106.887794
i=45, x0=127, y0=127, x=199, y=55, r=101.823380
i=46, x0=127, y0=127, x=199, y=64, r=95.671310
i=47, x0=127, y0=127, x=198, y=73, r=89.202019
i=48, x0=127, y0=127, x=196, y=84, r=81.301903
i=49, x0=127, y0=127, x=193, y=97, r=72.498276
i=50, x0=127, y0=127, x=190, y=109, r=65.520988
i=51, x0=127, y0=127, x=186, y=123, r=59.135437
i=52, x0=127, y0=127, x=181, y=135, r=54.589375
i=53, x0=127, y0=127, x=175, y=149, r=52.801514
i=54, x0=127, y0=127, x=169, y=161, r=54.037025
i=55, x0=127, y0=127, x=163, y=172, r=57.628117
i=56, x0=127, y0=127, x=156, y=181, r=61.294373
i=57, x0=127, y0=127, x=149, y=189, r=65.787537
i=58, x0=127, y0=127, x=142, y=195, r=69.634758
i=59, x0=127, y0=127, x=134, y=198, r=71.344238