home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- NOTES ON TRIG FUNCTIONS FOR BDS - C
-
-
- Introduction
-
-
- These trig functions were developed so that I could do some auxiliary work
-
- on scaling and curve generation for a graphics package I'm now doing in BDS-C.
-
- They seem to work OK in my setup which is now:
-
- o Altair 8800b, 64K CPM 2.2 BDS-C vers 1.42
-
- o Tarbell SSSD 4 8 inch disk
-
- o Scion Microangelo
-
- o LSI ADM3A
-
- This package was developed by:
-
- L. C. Calhoun PE
-
- 257 South Broadway
-
- Lebanon, Ohio 45036
-
- <513> 932-4541/433-7510
-
-
-
- These programs are written in BDS-C using the floating point package
-
- modified to add truncation and magnitude functions. This package is called
-
- "FLOATXT". The following functions are mechanized:
-
- char *sine(result,angle)
-
- char *result, *angle; /* usual [5] char arrays for fp */
-
- The angle input argument is in radians, within the bounds of the
-
- floating point variable. The function returns the pointer to the
-
- result.
-
- char *cosine(result,angle)
-
- char *result, *angle; /* as with sine */
-
- Identical to the sine
-
- char *tangent(result,angle)
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
- char *result, *angle; /*as with sine */
-
- char *arctan(angle,datum)
-
- char *angle, *datum;
-
- This returns the angle in radians. Error conditions, such as too
-
- small or large a datum return "end value" angles. There is no
-
- over/underflow indication. Also returns pointer to result.
-
- char *degtorad(rad, deg)
-
- char *rad, *deg;
-
- Converts an angle in degrees to an angle in radians, for use with the
-
- main functions. Also returns pointer to result.
-
- char *radtodeg(deg, rad)
-
- char *deg, *rad;
-
- Yep, inverse of degtorad Also returns pointer to result.
-
- Method
-
-
- The methods used are outlined in "Functional Approximations" by Fred
-
- Ruckdeschel; page 34 ff in BYTE for November 1978. Note the corrections in the
-
- January 1979 issue. A number of references are given in that article, and are
-
- recommended reading. The following service functions are used:
-
- char *sinev(result,angle)
-
- char *result, *angle;
-
- This is used for both sine and cosine, with the angle reduced to the
-
- range from - pi/2 to + pi/2. Also returns pointer to result.
-
- char *atanev(angle,result)
-
- char *angle, *result;
-
- This is used for the arctangent evaluation after it is checked for end
-
- value and mid value conditions. Returns result in radians, in the
-
- range from 0 (almost) to pi/2 for input arguments between 0 (almost)
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
-
- and infinity (almost). Also returns pointer to result.
-
-
-
- A number of checks are made for very large and very small data, to protect
-
- the evaluation from the underflow and overflow failures of the floating point
-
- package. I have used TESTTRIG to evaluate over a wide range of variables, and I
-
- think! I got all the gotchas. It looks as though the package has (except at
-
- infinity) about an absolute accuracy of .00001. You will note that I use the
-
- properties of the floating point numbers to do magnitude and sign checks. Lots
-
- faster than using fpcomp(). There is another program included, COEFSET, which I
-
- used to derive the five decimal equivalents for the constant terms in the series
-
- evaluations, etc. It appears much faster to use initb() to store floating point
-
- constants than to use *atof().
-
-
-
- Components of the CTRIG Package
- 1. CTRIG.DOC This documentation file
-
- 2. CTRIG.C Source for trig package
-
- 3. COEFSET.C Source for coeficient determing program
-
- 4. TRIGTEST.C Source for trig function testing program
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
-
-
- d sign checks. Lots
-
- faster than u