Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- using ld = long double;
- struct base {
- ld x, y;
- base(ld _x = 0, ld _y = 0): x(_x), y(_y) {}
- base operator *(const base& ot) const {
- return {x * ot.x - y * ot.y, x * ot.y + y * ot.x};
- }
- };
- const int N = 1 << 6;
- base angles[N];
- int main() {
- const ld pi = acosl(-1);
- const base root{cos(2 * pi / N), sin(2 * pi / N)};
- angles[0] = 1;
- for (int i = 1; i < N; ++i) {
- angles[i] = angles[i - 1] * root;
- if (!(i & 7)) {
- angles[i] = {cos(2 * pi / N * i), sin(2 * pi / N * i)};
- if (i == N / 4) {
- printf("%d\n", (int)(2 * pi / N * i == pi / 2));
- printf(" angles: %.5lf %.5lf\n", (double)(2 * pi / N * i), (double)(pi / 2));
- printf("cosines: %.5lf %.5lf\n", (double)cos(2 * pi / N * i), (double)cos(pi / 2));
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment