home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 3 / RISC_DISC_3.iso / resources / etexts / gems / gemsv / ch4_9 / lincrvte.c < prev   
Encoding:
C/C++ Source or Header  |  1995-04-04  |  1.5 KB  |  52 lines

  1. /*** lincrvtest.c ***/
  2.  
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <math.h>
  6. #include "lincrv.h"
  7.  
  8. #define TRUE 1
  9. #define FALSE 0
  10. #define BIG (1.0e12)
  11.  
  12. static Vect work[4];
  13. static Vect ctlPts[] = { {0,0}, {1,1}, {1,0}, {0,0}, };
  14. static float *knots;
  15. static float bezKts[] = {0, 0, 0, 1, 1, 1, BIG};
  16. static float lagKts[] = {0.00, 0.25, 0.75, 1.00, BIG};
  17. static float catKts[] = {-1, 0, 1, 2, BIG};
  18. static float bspKts[] = {-2, -1, 0, 1, 2, 3, BIG};
  19. static int m = MAXDIM;
  20. static int n = 3;
  21. static int Cn = 1;
  22. static Bool interp = FALSE;
  23. static Vect val = {0.84375, 0.0};
  24. static float t = 0;
  25. static int eh = 0;
  26.  
  27. enum Flavor{PLY, LAG, BEZ, CAT, BSP, NFLAVORS};
  28. char fnames[][4] = {"PLY", "LAG", "BEZ", "CAT", "BSP"};
  29.  
  30. void main(void)
  31. {
  32.     int i;
  33.     int flavor = PLY;
  34.     
  35.     for (flavor=0; flavor<NFLAVORS; flavor++) {
  36.         switch (flavor) {
  37.         case PLY:   knots = lagKts; interp = TRUE;  Cn = 0; break;
  38.         case LAG:   knots = lagKts; interp = TRUE;  Cn = 2; break;
  39.         case BEZ:   knots = bezKts; interp = FALSE; Cn = 2; break;
  40.         case CAT:   knots = catKts; interp = TRUE;  Cn = 1; break;
  41.         case BSP:   knots = bspKts; interp = FALSE; Cn = 2; break;
  42.         default:    knots = bspKts; interp = FALSE; Cn = 0; break;
  43.         }
  44.         printf("Flavor %s: interp=%d, Cn=%d\n", fnames[flavor],interp,Cn);
  45.         for (t=0.0; t<=1.0; t+=0.125) {
  46.             eh = DialASpline(t, knots, ctlPts, m, n, work, Cn, interp, val);
  47.             printf("(%6.3f) ", t);
  48.             for (i=0; i<MAXDIM; i++) printf("%9.6f ",val[i]); printf("\n");
  49.         }
  50.     }
  51. }
  52.