home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / vifs / xdistran.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-10  |  1.3 KB  |  63 lines

  1. /*
  2.  *    xdistrans.c  --  xor display transformation function for edtrans().
  3.  *
  4.  *    9 july 1989  Olle Olsson.
  5.  */
  6.  
  7. #include "edtrans.h"
  8.  
  9. void xdistrans( tp, ap )
  10. transform *tp;        /* the transform */
  11. area *ap;
  12. {
  13. #define NPT 6            /* number of points */
  14. register int i, j;
  15. double xt;
  16. double x[NPT], y[NPT];        /* transformation corners */
  17. int sxy[NPT * 2];        /* xorpolyline() x,y coordinates */
  18.  
  19. /* (xor-) display the the transform */
  20.  
  21. /* set corners (origin first and last) */
  22. /*x[0] = x[3] = x[4] = ap -> xlow;
  23. y[0] = y[1] = y[4] = ap -> ylow;
  24. x[1] = x[2] = ap -> xlow + ap -> xlen;
  25. y[2] = y[3] = ap -> ylow + ap -> ylen;
  26. */
  27. x[0] = x[3] = x[4] = 0;
  28. y[0] = y[1] = y[4] = 0;
  29. x[1] = x[2] = 1;
  30. y[2] = y[3] = 1;
  31.  
  32. /* mark the origin (and the direction of the x axis) with a fifth line */
  33. x[5] = x[1] / 5;
  34. y[5] = y[2] / 20;
  35.  
  36. /* do the transformation */
  37. for (i = 0; i < NPT; ++i)
  38.     {
  39.     xt   = tp -> a11 * x[i] + tp -> a12 * y[i] + tp -> b1;
  40.     y[i] = tp -> a21 * x[i] + tp -> a22 * y[i] + tp -> b2;
  41.     x[i] = xt;
  42.     }
  43.  
  44.  
  45. /* find the screen coordinates (y is upside down) */
  46. for (i = j = 0; i < NPT; ++i)
  47.     {
  48.     /* x */
  49.     sxy[j++] = MAX_COL * (x[i] - ap -> xlow) / ap -> xlen;
  50.  
  51.     /* y */
  52.     sxy[j++] = MAX_ROW * (1 - (y[i] - ap -> ylow) / ap -> ylen);
  53.     }
  54.  
  55. /* draw it */
  56. xorpolyline( NPT, sxy );
  57.  
  58. #undef NPT
  59. }
  60.  
  61.  
  62.  
  63.