home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 141_01 / trigplot.c < prev   
Text File  |  1985-03-10  |  2KB  |  57 lines

  1. /* trigplot.c -- point-by-point plot of sine, cosine */
  2. /* 1984 apr 22 pmkrasno */
  3. #include "bdscio.h"
  4. #include "float.h"
  5. #define XSCALE "120.0"
  6. #define YSCALE "90.0"
  7. #define WH 1    /* colors */
  8. #define BL 15
  9. #define wait pause () ; getchar () 
  10.  
  11. main ()    {    /* read x, y & plot */
  12.     float x[241], y[2*241] ;
  13.     float *sine (), *cosine () ; 
  14.     /* array of pointers to functions returning 
  15.         pointers to float !! */
  16.     float xscale[1], yscale[1] ;
  17.     float ulim[1], llim[1] ;
  18.     float delta[1], sx[1], sy[1], tx[1] ;
  19.     unsigned n, npts, secs1, secs2 ;
  20.     byte time1[13], time2[13], time3[13] ;
  21.     byte dif12[13+5], dif23[13+5] ;
  22.  
  23. /* cleanup scaling, delta */
  24.     atof (yscale, YSCALE) ;
  25.     atof (xscale, XSCALE) ; fpdiv (xscale, xscale, TWOPI) ;
  26.     atof (delta, XSCALE)  ; fpdiv (delta, TWOPI, delta) ;
  27.     fpasg (llim, MTWOPI)  ; fpasg (ulim, TWOPI) ;
  28.     mode2 () ; cls (WH, BL) ;
  29.  
  30.     npts = 1 + ftoir (
  31.         fpdiv (tx, fpsub (tx, ulim, llim), delta)) ;
  32.         /* npts = 1 + ((ulim - llim) / delta) ; */
  33.     axes (0, 0) ;
  34.  
  35.     syst_d (time1) ; 
  36.     printf ("Evaluate %d points: %s\N", 2*npts, time1) ;
  37.     comp_pts (npts, 2, x, y, llim, delta, sine, cosine) ;
  38.  
  39.     syst_d (time2) ;
  40.     printf ("Plot %d points:     %s\N", 2*npts, time2) ;
  41.     plot_pts (npts, 2, x, y, xscale, yscale) ;
  42.  
  43.     syst_d (time3) ;
  44.     printf ("Done :               %s\N", time3) ;
  45.     secs1 = tim_dif (dif12, time2, time1) ;
  46.     secs2 = tim_dif (dif23, time2, time3) ;
  47.     /* convert differences to seconds */
  48.     printf ("Evaluate: %d secs; Plot: %d secs\N", 
  49.         secs1, secs2) ;
  50. } /* main */
  51.  
  52. 
  53.     unsigned n, npts, secs1, secs2 ;
  54.     byte time1[13], time2[13], time3[13] ;
  55.     byte dif12[13+5], dif23[13+5] ;
  56.  
  57. /* cleanu