home *** CD-ROM | disk | FTP | other *** search
- #include "arch.h"
-
- double sin(a)
- double a;
- {
- register int i, q;
- float h;
- float fa = a, ftbpi = TBPI, fst = ST;
-
- h = fa * ftbpi;
- i = h * fst;
- q = h;
- if (i < 0) {
- i = -i;
- q = 2 - q;
- }
- switch (q & 03) {
- case 0 :
- return(st[i & MMAS]);
- case 1 :
- return(st[ST - 1 - (i & MMAS)]);
- case 2 :
- return(-st[i & MMAS]);
- case 3:
- return(-st[ST - 1 - (i & MMAS)]);
- }
- }
-
-
- double cos(a)
- double a;
- {
- register int i, q;
- float h;
- float fa = a, ftbpi = TBPI, fst = ST;
-
- h = fa * ftbpi;
- i = h * fst; i += ST;
- q = h + 1;
- if (i < 0) {
- i = -i;
- q = -q + 2;
- }
- switch (q & 03) {
- case 0 :
- return(st[i & MMAS]);
- case 1 :
- return(st[ST - 1 - (i & MMAS)]);
- case 2 :
- return(-st[i & MMAS]);
- case 3:
- return(-st[ST - 1 - (i & MMAS)]);
- }
- }
-
-
- #define ABS(n) ((n < 0.) ? -n : n)
-
- double atan2(y, x)
- double y, x;
- {
- register int i;
- float fy = y, fx = x;
- float fat = AT, h;
-
- if (fy + fx == fy) {
- if (fy >= 0.) {
- return(PIB2);
- }
- else {
- return(-PIB2);
- }
- }
- if (ABS(fy) <= ABS(fx)) {
- h = fy / fx;
- h *= fat;
- i = h;
- if (fx > 0.) {
- if (fy > 0.) {
- return(at[i]);
- }
- else {
- return(-at[-i]);
- }
- }
- else {
- if (fy > 0.) {
- return(PI - at[-i]);
- }
- else {
- return(-PI + at[i]);
- }
- }
- }
- else {
- h = fx / fy;
- h *= fat;
- i = h;
- if (fx > 0.) {
- if (fy > 0.) {
- return(PIB2 - at[i]);
- }
- else {
- return(-PIB2 + at[-i]);
- }
- }
- else {
- if (fy > 0.) {
- return(PIB2 + at[-i]);
- }
- else {
- return(-PIB2 - at[i]);
- }
- }
- }
- }
-