1: /*
   2: #	TRIG(3.icon)
   3: #
   4: #	Trigonometric functions
   5: #
   6: #	Ralph E. Griswold and Stephen B. Wampler
   7: #
   8: #	Last modified 8/19/84
   9: #
  10: */
  11: 
  12: #include "../h/rt.h"
  13: #include <errno.h>
  14: 
  15: int errno;
  16: 
  17: /*
  18:  * sin(x), x in radians
  19:  */
  20: Xsin(nargs, arg1, arg0)
  21: int nargs;
  22: struct descrip arg1, arg0;
  23:    {
  24:    int t;
  25:    union numeric r;
  26:    double sin();
  27: 
  28:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  29:    mkreal(sin(r.real),&arg0);
  30:    }
  31: Procblock(sin,1)
  32: 
  33: /*
  34:  * cos(x), x in radians
  35:  */
  36: Xcos(nargs, arg1, arg0)
  37: int nargs;
  38: struct descrip arg1, arg0;
  39:    {
  40:    int t;
  41:    union numeric r;
  42:    double cos();
  43: 
  44:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  45:    mkreal(cos(r.real),&arg0);
  46:    }
  47: Procblock(cos,1)
  48: 
  49: /*
  50:  * tan(x), x in radians
  51:  */
  52: Xtan(nargs, arg1, arg0)
  53: int nargs;
  54: struct descrip arg1, arg0;
  55:    {
  56:    int t;
  57:    double y;
  58:    union numeric r;
  59:    double tan();
  60: 
  61:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  62:    y = tan(r.real);
  63:    if (errno == ERANGE) runerr(252, NULL);
  64:    mkreal(y,&arg0);
  65:    }
  66: Procblock(tan,1)
  67: 
  68: /*
  69:  * acos(x), x in radians
  70:  */
  71: Xacos(nargs, arg1, arg0)
  72: int nargs;
  73: struct descrip arg1, arg0;
  74:    {
  75:    int t;
  76:    double y;
  77:    union numeric r;
  78:    double acos();
  79: 
  80:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  81:    y = acos(r.real);
  82:    if (errno == EDOM) runerr(251, NULL);
  83:    mkreal(y,&arg0);
  84:    }
  85: Procblock(acos,1)
  86: 
  87: /*
  88:  * asin(x), x in radians
  89:  */
  90: Xasin(nargs, arg1, arg0)
  91: int nargs;
  92: struct descrip arg1, arg0;
  93:    {
  94:    int t;
  95:    double y;
  96:    union numeric r;
  97:    double asin();
  98: 
  99:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
 100:    y = asin(r.real);
 101:    if (errno == EDOM) runerr(251, NULL);
 102:    mkreal(y,&arg0);
 103:    }
 104: Procblock(asin,1)
 105: 
 106: /*
 107:  * atan(x), x in radians
 108:  */
 109: Xatan(nargs, arg1, arg0)
 110: int nargs;
 111: struct descrip arg1, arg0;
 112:    {
 113:    int t;
 114:    union numeric r;
 115:    double atan();
 116: 
 117:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
 118:    mkreal(atan(r.real),&arg0);
 119:    }
 120: struct b_iproc Batan = {
 121:    T_PROC,
 122:    sizeof(struct b_proc),
 123:    EntryPoint(Xatan),
 124:    1,
 125:    -1,
 126:    0,
 127:    0,
 128:    {4, "atan"}
 129:    };
 130: 
 131: /*
 132:  * atan2(x,y), x, y in radians
 133:  */
 134: Xatan2(nargs, arg2, arg1, arg0)
 135: int nargs;
 136: struct descrip arg2, arg1, arg0;
 137:    {
 138:    int t;
 139:    union numeric r1, r2;
 140:    double atan2();
 141: 
 142:    if ((t = cvreal(&arg2, &r2)) == NULL) runerr(102, &arg2);
 143:    if ((t = cvreal(&arg1, &r1)) == NULL) runerr(102, &arg1);
 144:    mkreal(atan2(r1.real,r2.real),&arg0);
 145:    }
 146: Procblock(atan2,2)
 147: 
 148: #define PI 3.14159
 149: 
 150: /*
 151:  * dtor(x), x in degrees
 152:  */
 153: Xdtor(nargs, arg1, arg0)
 154: int nargs;
 155: struct descrip arg1, arg0;
 156:    {
 157:    union numeric r;
 158: 
 159:    if (cvreal(&arg1, &r) == NULL) runerr(102, &arg1);
 160:    mkreal(r.real * PI / 180, &arg0);
 161:    }
 162: Procblock(dtor,1)
 163: 
 164: /*
 165:  * rtod(x), x in radians
 166:  */
 167: Xrtod(nargs, arg1, arg0)
 168: int nargs;
 169: struct descrip arg1, arg0;
 170:    {
 171:    union numeric r;
 172: 
 173:    if (cvreal(&arg1, &r) == NULL) runerr(102, &arg1);
 174:    mkreal(r.real * 180 / PI, &arg0);
 175:    }
 176: Procblock(rtod,1)

Defined functions

Procblock defined in line 162; never used
Xacos defined in line 66; never used
Xasin defined in line 85; never used
Xatan defined in line 104; used 1 times
Xatan2 defined in line 134; never used
Xcos defined in line 31; never used
Xdtor defined in line 146; never used
Xrtod defined in line 162; never used
Xsin defined in line 20; never used
Xtan defined in line 47; never used

Defined variables

Batan defined in line 120; never used
errno defined in line 15; used 3 times

Defined macros

PI defined in line 148; used 2 times
Last modified: 1984-08-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1164
Valid CSS Valid XHTML 1.0 Strict