aboutsummaryrefslogtreecommitdiff
path: root/Semestr 3/anm/cordic/csin.cpp
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
commitc5fcf7179a83ef65c86c6a4a390029149e518649 (patch)
treed29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 3/anm/cordic/csin.cpp
parentf8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff)
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 3/anm/cordic/csin.cpp')
-rw-r--r--Semestr 3/anm/cordic/csin.cpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/Semestr 3/anm/cordic/csin.cpp b/Semestr 3/anm/cordic/csin.cpp
deleted file mode 100644
index bcc9af4..0000000
--- a/Semestr 3/anm/cordic/csin.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "CORDICtable.c"
-#include <iostream>
-// angle is radians multiplied by CORDIC multiplication factor M
-// modulus can be set to CORDIC inverse gain 1/F to avoid post-division
-void CORDICsincos(int a, int m, int *s, int *c)
-{
- int k, tx, x = m, y = 0, z = a, fl = 0;
- if (z > +CORDIC_HALFPI)
- {
- fl = +1;
- z = (+CORDIC_PI) - z;
- }
- else if (z < -CORDIC_HALFPI)
- {
- fl = +1;
- z = (-CORDIC_PI) - z;
- }
- for (k = 0; k < CORDIC_MAXITER; k++)
- {
- std::cout << x << " " << y << " " << z << "\n";
- tx = x;
- if (z >= 0)
- {
- x -= (y >> k);
- y += (tx >> k);
- z -= CORDIC_ZTBL[k];
- }
- else
- {
- x += (y >> k);
- y -= (tx >> k);
- z += CORDIC_ZTBL[k];
- }
- }
- if (fl)
- x = -x;
- *c = x; // m*cos(a) multiplied by gain F and factor M
- *s = y; // m*sin(a) multiplied by gain F and factor M
-}
-
-int main()
-{
- double x;
- std::cin >> x;
- int sinus, cosinus;
- CORDICsincos(x * CORDIC_MUL, CORDIC_1F, &sinus, &cosinus);
- std::cout << sinus << " " << cosinus << "\n";
- std::cout << (double)sinus / (double)CORDIC_MUL << " " << (double)cosinus / (double)CORDIC_MUL << "\n";
-} \ No newline at end of file