Guest User

absolute_garbage.cpp

a guest
Oct 13th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3.  
  4. using ld = long double;
  5.  
  6. struct base {
  7.     ld x, y;
  8.  
  9.     base(ld _x = 0, ld _y = 0): x(_x), y(_y) {}
  10.  
  11.     base operator *(const base& ot) const {
  12.         return {x * ot.x - y * ot.y, x * ot.y + y * ot.x};
  13.     }
  14. };
  15.  
  16. const int N = 1 << 6;
  17. base angles[N];
  18.  
  19. int main() {
  20.     const ld pi = acosl(-1);
  21.     const base root{cos(2 * pi / N), sin(2 * pi / N)};
  22.     angles[0] = 1;
  23.     for (int i = 1; i < N; ++i) {
  24.         angles[i] = angles[i - 1] * root;
  25.         if (!(i & 7)) {
  26.             angles[i] = {cos(2 * pi / N * i), sin(2 * pi / N * i)};
  27.             if (i == N / 4) {
  28.                 printf("%d\n", (int)(2 * pi / N * i == pi / 2));
  29.                 printf(" angles: %.5lf %.5lf\n", (double)(2 * pi / N * i), (double)(pi / 2));
  30.                 printf("cosines: %.5lf %.5lf\n", (double)cos(2 * pi / N * i), (double)cos(pi / 2));
  31.             }
  32.         }
  33.     }
  34.  
  35.     return 0;
  36. }
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment