home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / ELIPRAI2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-20  |  2.8 KB  |  70 lines

  1. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. procedure StrokeEllipse ( xc, yc : integer ; { center }
  4.                             a, b : word ; { radii }
  5.                               ta : single ) ; { rotation angle (rad) }
  6.  
  7.      { ElipRAI2 - draw ellipse using rotation angle method }
  8.      {            with `increment' angle step and semi-    }
  9.      {            circular symmetry                        }
  10.  
  11. var
  12.    ixar,iyar        : word ;    { aspect ratio parameters }
  13.    iar              : longint ; { aspect ratio B16 }
  14.    icosta,isinta    : longint ; { rotation angle functions B16 }
  15.    ira,irb          : longint ; { offset radii B6 }
  16.    ida              : integer ; { loop control }
  17.    it,ixa,iya       : longint ; { coordinate variables B6 }
  18.    ixb,iyb          : longint ; { coordinate variables B6 }
  19.    ix0,iy0,ix1,iy1  : integer ; { display coordinates B0 }
  20.  
  21. begin
  22.                                 { constraint test }
  23.    if (a < 510) and (b < 510) then begin
  24.                                 { aspect ratio }
  25.       GetAspectRatio(ixar,iyar) ;
  26.       iar := SwapLong(longint(ixar)) div longint(iyar) ;
  27.                                 { rotate, offset, prescale, }
  28.                                 { aspect and reflect        }
  29.       icosta := Round(cos(ta) * 65536) ;
  30.       isinta := Round(sin(ta) * 65536) ;
  31.  
  32.       ira := a shl 6 + idr ;
  33.       irb := b shl 6 + idr ;
  34.  
  35.       ixa := RoundScaleB16(ira * icosta) ;
  36.       iya := -RoundScaleB16(irb * isinta) ;
  37.  
  38.       ixb := RoundScaleB16(RoundScaleB16(irb * icosta) * iar) ;
  39.       iyb := -RoundScaleB16(RoundScaleB16(ira * isinta) * iar) ;
  40.                                 { starting point }
  41.       ix0 := RoundScaleB6(ixa) ;
  42.       iy0 := RoundScaleB6(iyb) ;
  43.                                 { ellipse }
  44.       for ida := 1 to 25 do begin
  45.                                 { rotate coordinates }
  46.          it := RoundScaleB16(((((ixa shl 3 - iya) shl 4 -
  47.                ixa) shl 5 - iya) shl 2 - iya) shl 2) ;
  48.          iya := RoundScaleB16(((((iya shl 3 + ixa) shl 4 -
  49.                 iya) shl 5 + ixa) shl 2 + ixa) shl 2) ;
  50.          ixa := it ;
  51.  
  52.          it := RoundScaleB16(((((ixb shl 3 - iyb) shl 4 -
  53.                ixb) shl 5 - iyb) shl 2 - iyb) shl 2) ;
  54.          iyb := RoundScaleB16(((((iyb shl 3 + ixb) shl 4 -
  55.                 iyb) shl 5 + ixb) shl 2 + ixb) shl 2) ;
  56.          ixb := it ;
  57.                                 { draw chord }
  58.          ix1 := RoundScaleB6(ixa) ;
  59.          iy1 := RoundScaleB6(iyb) ;
  60.          Line(xc+ix0,yc+iy0,xc+ix1,yc+iy1) ;
  61.          Line(xc-ix0,yc-iy0,xc-ix1,yc-iy1) ;
  62.                                 { ladder down }
  63.          ix0 := ix1 ;  iy0 := iy1
  64.  
  65.       end
  66.    end
  67. end ;
  68.  
  69. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  70.