home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / CONIC.DOC < prev    next >
Encoding:
Text File  |  1989-01-23  |  92.7 KB  |  2,509 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                 `Minimum' CONICS
  7.  
  8.                                    Version 1.1
  9.                                     01/19/89
  10.  
  11.  
  12.                                    Adam Fritz
  13.                                  133 Main Street
  14.                               Afton, New York 13730
  15.  
  16.  
  17.                   Permission is hereby granted to copy and 
  18.                   distribute this document and associated rou-
  19.                   tines for any non-commercial purpose.  Any 
  20.                   use of this material for commercial advantage 
  21.                   without prior written consent of the author 
  22.                   is prohibited.
  23.  
  24.  
  25.         INTRODUCTION
  26.         ============
  27.  
  28.                This writeup presents and discusses a collection of rou-
  29.         tines for drawing conic sections with points and line segments 
  30.         whose coordinates are generated using rotation of coordinates 
  31.         methods.  Timing performance comparisons are made to routines 
  32.         using offset error methods, aka Bresenham.  
  33.  
  34.                This writeup is distributed with two different versions, 
  35.         viz. CNC11TP.ARC and CNC11TM.ARC where the first contains TURBO 
  36.         Pascal (c) 4.0 routines and the second contains TopSpeed MODULA-2 
  37.         (c) 1.14 routines.  See DISTRIBUTION below.
  38.  
  39.  
  40.         DISCUSSION
  41.         ==========
  42.  
  43.         Polygons
  44.  
  45.               Vertex coordinates for a regular polygon with radius r 
  46.         might be computed:
  47.  
  48.                         2 Pi
  49.            x  = r cos(i ----)
  50.             i            n
  51.  
  52.                         2 Pi
  53.            y  = r sin(i ----)
  54.             i            n
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                An algorithm to use these formulae can be outlined:
  71.  
  72.            move(r,0)
  73.            da = 2*Pi/n
  74.            for i = 1 to n do begin
  75.               a = i*da
  76.               draw(r*cos(a),r*sin(a))
  77.            end 
  78.  
  79.         where i is vertex index and n is number of sides.  An algorithm 
  80.         based on these formulae would require n sine and cosine evalua-
  81.         tions or n-1 if the identity of starting and ending points is 
  82.         noted.  Suppose, instead, that the sine and cosine at index i are 
  83.         computed and those at i+1 are desired.  Let `a' be angle at i and 
  84.         `da' be step angle = 2Pi/n.  One way is to use sum angle formulae 
  85.         where:
  86.  
  87.            cos(a + da) = cos(a) * cos(da) - sin(a) * sin(da)
  88.            sin(a + da) = sin(a) * cos(da) + cos(a) * sin(da)
  89.  
  90.         and sine and cosine of `da' need be computed just once at first 
  91.         vertex as do sine and cosine of initial vertex angle.  Each 
  92.         subsequent vertex requires just four multiplies and two addi-
  93.         tions.  If vertex angle functions are initialized to include an 
  94.         offset rotation angle `ta' then an algorithm to draw a polygon can 
  95.         be outlined:
  96.  
  97.            da = 2*Pi/n
  98.            cosda = cos(da)
  99.            sinda = sin(da)
  100.            cosa = cos(ta)
  101.            sina = sin(ta)
  102.            move(r*cosa,r*sina)
  103.            for i = 1 to n do begin
  104.               t = cosa * cosda - sina * sinda
  105.               sina = sina * cosda + cosa * sinda
  106.               cosa = t
  107.               draw(r*cosa,r*sina)
  108.            end
  109.          
  110.                Routine POLYRA.PAS is a TURBO Pascal 4.0 floating point 
  111.         routine to apply this algorithm and includes the effects of 
  112.         aspect ratio, a specified center, and inverted vertical coordi-
  113.         nate.  Procedure PolyRA in POLYGON.MOD is a TopSpeed Modula-2 
  114.         1.14 routine with the same features.  In general, routines with 
  115.         `*RA*.x' names use this `rotation angle' approach.  
  116.  
  117.                Computations can be done in fixed point arithmetic rather 
  118.         than floating point.  Sines and cosines vary from -1.0 to 1.0 so 
  119.         that if a 16 bit integer is used to represent this range it is 
  120.         convenient to scale sine or cosine at B14.  That is, the imagined 
  121.         binary point is to the right of bit 14 when the bits are labeled 
  122.         right to left.  For example, 1@B12 = b0001.0000 0000 0000, where 
  123.         the binary point is imagined, 1@B2 = $0004, etc.
  124.  
  125.  
  126.  
  127.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                If values are coded fixed point then it is more convenient 
  137.         to make them longint rather than integer for formation of 
  138.         products and dividends.  The algorithm above can be rewritten so 
  139.         that the loop is done in fixed point:
  140.  
  141.            da = 2*Pi/n
  142.            icosda = round(cos(da)*16384)
  143.            isinda = round(sin(da)*16384)
  144.            icosa = round(cos(ta)*16384)
  145.            isina = round(sin(ta)*16384)
  146.            ix = longhi(r*icosa shl 2)
  147.            iy = longhi(r*isina shl 2)
  148.            move(ix,iy)
  149.            for i = 1 to n do begin
  150.               it = longhi((icosa * icosda - isina * isinda) shl 2)
  151.               isina = longhi((isina * icosda + icosa * isinda) shl 2)
  152.               icosa = it
  153.               ix = longhi(r*icosa shl 2)
  154.               iy = longhi(r*isina shl 2)
  155.               draw(ix,iy)
  156.            end
  157.  
  158.         where angle functions are scaled B14 and radius r and display 
  159.         coordinates ix and iy are scaled B0.  LongHi is a function that 
  160.         swaps the high order 16 bits of a 32 bit operand to low order 16
  161.         bits and does sign extend - see file CONIC which includes several 
  162.         utility values and routines.  Similar routines for Modula-2 are 
  163.         found in MathFun.MOD.  Obviously, r greater than 32767 will 
  164.         produce overflow.  
  165.  
  166.                Routine POLYRAF is a fixed point routine using this 
  167.         method that includes aspect correction, offset (discussed below), 
  168.         and coordinate reflection.  It also computes rotation on radiused 
  169.         circle scaled B6 rather than unit circle scaled B14.  A generic 
  170.         driver is found in DEMOPOLY that enables selection of algo-
  171.         rithm, and specification of parameters for radius, number of 
  172.         sides,  and rotation angle.  A driver to estimate average time is 
  173.         presented in BNCHPOLY where timing is compared to TURBO's BGI 
  174.         Circle routine.  Timing results with and without a numeric co-
  175.         processor are tabulated in the PERFORMANCE section below. 
  176.  
  177.                It is possible to generate sines and cosines, among other 
  178.         things, using second order linear difference equations.  For 
  179.         example, the form for such a generator is:
  180.  
  181.            z  = c * z    - z   
  182.             n        n-1    n-2
  183.  
  184.         where, for circular functions, `c' is computed 2 * cos(da) and 
  185.         z    and z    are initialized to any two successive function
  186.          n-1      n-2 
  187.         values separated by da.  Using this relationship for a polygon 
  188.         generator can be outlined:
  189.  
  190.  
  191.  
  192.  
  193.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.            da = 2*Pi/n
  203.            cosda2 = 2*cos(da)
  204.            cos1 = cos(ta)
  205.            cos2 = cos(ta-da)
  206.            sin1 = sin(ta)
  207.            sin2 = sin(ta-da)
  208.            move(r*cos1,r*sin1)
  209.            for i = 1 to n do begin
  210.               cos0 = cosda2 * cos1 - cos2
  211.               sin0 = cosda2 * sin1 - sin2
  212.               draw(r*cos0,r*sin0)
  213.               cos2 = cos1
  214.               cos1 = cos0
  215.               sin2 = sin1
  216.               sin1 = sin0
  217.            end
  218.  
  219.         where a generator is assigned to each sine and cosine which 
  220.         requires just two multiplies and two additions for each vertex.  
  221.         Routine POLYDA is a floating point and POLYDAF is a fixed point 
  222.         routine to apply this `difference' angle algorithm with DEMOPOLY 
  223.         and BNCHPOLY provisions similar to those for the rotation angle 
  224.         routines.  Similar routines for circles, ellipses, and hyperbolae 
  225.         use a `*DA*.x' syntax.
  226.          
  227.  
  228.         Incremental Angles
  229.  
  230.                If the above routines are used to generate polygons on a
  231.         graphics plane with finite resolution there is some number of 
  232.         sides n such that the polygon with n+1 sides is not readily 
  233.         distinguished.  For a Hercules (tm) graphics adapter with 720x348 
  234.         resolution this happens for n between 25 and 30.  Further, for 
  235.         this value there is no marked distinction between a polygon and a 
  236.         circle generated with an offset error routine, e.g., Bresenham's 
  237.         circle algorithm.  This suggests the idea of using polygons to 
  238.         approximate circles.
  239.  
  240.                If a regular polygon with n sides is inscribed in a circle 
  241.         with radius r then the maximum distance between circumference and 
  242.         chord is:
  243.          
  244.                            da
  245.            dr = r [1 - cos(--)]
  246.                             2
  247.  
  248.         where da = 2Pi/n is the step angle.  If dr is required to be no 
  249.         greater than 0.5, i.e. half a pixel, then:
  250.  
  251.                da          1
  252.            cos(--) >= 1 - --
  253.                 2         2r
  254.  
  255.  
  256.  
  257.  
  258.  
  259.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.         and the step angle can be estimated, via series expansions:
  269.          
  270.                          1
  271.            da <= 2 sqrt( - )
  272.                          r
  273.  
  274.                An integer number of sides is convenient, but not 
  275.         essential, but requires:
  276.  
  277.                        2 Pi
  278.            n >= Round( ---- )
  279.                         da
  280.  
  281.         with da readjusted:
  282.  
  283.                 2 Pi
  284.            da = ----
  285.                   n
  286.  
  287.                These relations claim that a polygon with n sides can fit 
  288.         a circle with radius r to within half a pixel if da is computed 
  289.         as indicated.  The following table shows r, n, and da for several 
  290.         values.  Routine DELCANG generates these values.
  291.  
  292.  
  293.                               DELTA ANGLES
  294.  
  295.            ==================================================
  296.                 |      exact     |  approximate   | adjusted
  297.            --------------------------------------------------
  298.              r  |    da       n  |    da       n  |    da
  299.                 |   (deg)        |   (deg)        |   (deg)
  300.            --------------------------------------------------
  301.               1  120.00000     3  114.59156     3  120.00000
  302.               2   82.81924     4   81.02847     4   90.00000
  303.               4   57.91005     6   57.29578     6   60.00000
  304.               8   40.72827     9   40.51423     9   40.00000
  305.              16   28.72302    13   28.64789    13   27.69231
  306.              32   20.28358    18   20.25712    18   20.00000
  307.              64   14.33329    25   14.32395    25   14.40000
  308.             128   10.13186    36   10.12856    36   10.00000
  309.             256    7.16314    50    7.16197    50    7.20000
  310.             512    5.06469    71    5.06428    71    5.07042
  311.            1024    3.58113   101    3.58099   101    3.56436
  312.            ==================================================
  313.  
  314.  
  315.                 Ignoring symmetry, the number of chords grows with the 
  316.         square root of radius.  The number of pixels using Bresenham 
  317.         circle grows linearly with radius.  This suggests chord genera-
  318.         tion is more efficient than Bresenham.  This is misleading 
  319.         because the chords are presumably drawn with Bresenham line to 
  320.         produce the same effective number of pixels.  Therefore, the 
  321.         comparison is between Bresenham line and Bresenham circle.
  322.  
  323.  
  324.  
  325.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.              The code for Bresenham line, for both x and y increasing and 
  335.         dx greater than dy looks like:
  336.  
  337.              ie := (dx+1) DIV 2 ;
  338.              LOOP
  339.                 Plot(x1,y1,c) ;
  340.                 IF x1 = x2 THEN EXIT END ;
  341.                 INC(x1) ;
  342.                 INC(ie,dy) ;
  343.                 IF ie > dx THEN
  344.                    DEC(ie,dx) ;
  345.                    INC(y1) ;
  346.                 END ;
  347.              END ;
  348.  
  349.         and the code for Bresenham circle, using octant symmetry and 
  350.         ignoring both aspect correction and symmetry looks like:
  351.  
  352.              WHILE ix < iy DO
  353.                 IF ie < 0 THEN
  354.                    ie := ie + 2*iy - 1 ;
  355.                    DEC(iy) ;
  356.                 END ;
  357.                 ie := ie - 2*ix - 1 ;
  358.                 INC(ix) ;
  359.  
  360.                 PLOT(xc+ix,yc+iy,c) ;
  361.  
  362.              END ;
  363.  
  364.              If details about symmetry and setup are ignored, then the 
  365.         differences between these loops are the error offset terms.  The 
  366.         offset terms can be computed by summing constant terms to form 
  367.         the linear  offsets.  Routine CircMB shows how this loop struc-
  368.         ture is only slightly complicated by incremental offset and 
  369.         aspect correction.  In effect the aspect corrected routine for 
  370.         circle about doubles the work per pixel over that for line.  It 
  371.         is this difference that makes it useful to consider stroke over 
  372.         pixel algorithms.  This difference grows with resolution.  Rou-
  373.         tines named `*MB*.x' use offset error methods where MB denotes 
  374.         modified Bresenham - the first published examples of this class 
  375.         of algorithm.  See Offset Error Methods somewhere below.  Rou-
  376.         tines named `*MBR*.x' include both rotation and aspect 
  377.         correction.
  378.  
  379.  
  380.         Incremental Angle
  381.  
  382.                Generating circles using polygons with two multiplies and 
  383.         two adds is interesting.  Is there anything faster?  Suppose that 
  384.         the sines and cosines of a step angle were very simple binary 
  385.         numbers, that is, had only a few bits set or not set.  Such 
  386.         values permit multiplication to be done with a few shifts and 
  387.         adds.  If a sine or cosine had just one bit set then a shift 
  388.         corresponding to the bit position would be a multiply.  Similar-
  389.  
  390.  
  391.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.         ly, floating point multiply might be done with exponent augmenta-
  401.         tion.
  402.  
  403.                Let angles be computed 360/n and their sines and cosines 
  404.         be computed and scaled Bxx.  Those angles listed below have 
  405.         minimum distinct set bit counts.  Routine INCCANG generates these 
  406.         numbers.  There are no such angles scaled B16 for radii less than 
  407.         2000 pixels using rounding to generate the scaled values.  There 
  408.         are some using truncation or a larger set bit count threshold.
  409.  
  410.  
  411.                            INCREMENTAL ANGLE B14
  412.  
  413.            =======================================================
  414.              n       ang      r     sin     cos    number of bits
  415.                     (deg)                          sin cos  total
  416.            -------------------------------------------------------
  417.              50    7.20000   253   $0805   $3F7F    3   -1    4
  418.             134    2.68657  1819   $0300   $3FEE    2   -2    4
  419.            =======================================================
  420.  
  421.  
  422.                            INCREMENTAL ANGLE B15
  423.  
  424.            =======================================================
  425.              n       ang      r     sin     cos    number of bits
  426.                     (deg)                          sin cos  total
  427.            -------------------------------------------------------
  428.             100    3.60000  1013   $080A   $7FBF    3   -1    4
  429.            =======================================================
  430.  
  431.  
  432.                For example, if the parameters for case n = 50 at B14 are 
  433.         used, then sine and cosine scaled B14 can be generated with the 
  434.         rotation angle algorithm by:
  435.  
  436.            it = icosa * icosda - isina * isinda
  437.            isina = isina * icosda + icosa * isinda
  438.            icosa = it
  439.  
  440.         or, using hex,
  441.            
  442.            it = icosa * $3F7F - isina * $0805
  443.            isina = isina * $3F7F + icosa * $0805
  444.            icosa = it 
  445.  
  446.         or, using binary,
  447.  
  448.            it = icosa * b0011111101111111 - isina * b000010000000 101
  449.            isina = isina * b0011111101111111 + icosa * b0000100000000101
  450.            icosa = it
  451.  
  452.         or, using complementarity, i.e. $3F7F = $4000 - $0080, and sub-
  453.         stituting ix = icosa, iy = isina,  with operands assumed to be 
  454.         longint,
  455.  
  456.  
  457.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.            it = ix shl 14 - ix shl 7 - iy shl 11 - iy shl 2 - iy
  468.            iy = iy shl 14 - iy shl 7 + ix shl 11 + ix shl 2 + ix
  469.            ix = it
  470.  
  471.         and, factoring,
  472.  
  473.            it = (((ix shl 3 - iy) shl 4 - ix) shl 5 - iy) shl 2 - iy
  474.            iy = (((iy shl 3 + ix) shl 4 - iy) shl 5 + ix) shl 2 + ix
  475.            ix = it
  476.  
  477.         where the operands are now scaled B28.  A further shift left two 
  478.         and capture of the high order 16 bits of a 32 bit longint operand 
  479.         with sign extension properly rescales - see RoundScale16 and 
  480.         LongHi functions in CONIC or MathFun.  That is, B28 + B2 - B16 = 
  481.         B14.  If instead, operands are scaled B30 then the bit operations 
  482.         can be to the right with `div' rather than `shr' which does not 
  483.         preserve sign.  Routine CIRCRAIR implements the rotation angle 
  484.         algorithm with right shifting for the same parameters used above.
  485.  
  486.                Routine CIRCRAI2 illustrates application of the parameters 
  487.         for n = 100 with scaling at B15.  Routines with names `*I*.x' 
  488.         denote usage of incremental angle values.
  489.  
  490.  
  491.         Incremental Cosine
  492.  
  493.                The limited selection of angles above suggests considera-
  494.         tion of difference equation generators where step angles with 
  495.         cosines having few distinct bits are sought.  Because only the 
  496.         cosine, rather than sine and cosine together, is considered, it 
  497.         can be expected there are more step angles and, therefore, more 
  498.         good fitting polygons available.
  499.  
  500.                If angles are again computed 360/n and their cosines are 
  501.         scaled Bxx then those angles listed below have minimum set bit 
  502.         counts.  Routine INCCOS genrates these tableau.
  503.  
  504.  
  505.                             INCREMENTAL COSINE B14
  506.  
  507.         =====================================================================
  508.           n       ang      sin     cos    2*cos     atan      r  nbit |nbit|
  509.                  (deg)                              (deg)        2cos  2cos
  510.         ---------------------------------------------------------------------
  511.            6   60.00000   $376D   $2000   $4000   60.00000     4    1    1
  512.          100    3.60000   $03FF   $3FE0   $7FBF    3.58157  1024   -1    1
  513.          139    2.58993   $02EA   $3FEF   $7FDF    2.61030  1927   -1    1
  514.          140    2.57143   $02D4   $3FF0   $7FDF    2.53235  2048   -1    1
  515.         =====================================================================
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                             INCREMENTAL COSINE B15
  533.  
  534.         =====================================================================
  535.           n       ang      sin     cos    2*cos     atan      r  nbit |nbit|
  536.                  (deg)                              (deg)        2cos  2cos
  537.         ---------------------------------------------------------------------
  538.            6   60.00000   $6EDA   $4000   $8000   60.00000     4    1    1
  539.          100    3.60000   $080F   $7FBF   $FF7F    3.60945  1008   -1    1
  540.          141    2.55319   $05BE   $7FDF   $FFBF    2.57162  1986   -1    1
  541.          197    1.82741   $041F   $7FEF   $FFDF    1.84568  3855   -1    1
  542.         =====================================================================
  543.  
  544.  
  545.                              INCREMENTAL COSINE B16
  546.  
  547.         =======================================================================
  548.           n       ang      sin     cos      2*cos     atan      r  nbit |nbit|
  549.                  (deg)                                (deg)        2cos  2cos
  550.         -----------------------------------------------------------------------
  551.            6   60.00000   $DDB4   $8000   $00010000   60.00000     4    1    1
  552.           71    5.07042   $169B   $FF00   $0001FDFF    5.06593   512   -1    1
  553.          199    1.80905   $081F   $FFDF   $0001FFBF    1.81833  3972   -1    1
  554.         =======================================================================
  555.  
  556.  
  557.                For example, take the case for n = 100 at B15 and compute 
  558.         sine and cosine scaled, say, B30.  Then,
  559.  
  560.            ix0 = i2cos * ix1 - ix2
  561.            iy0 = i2cos * iy1 - iy2
  562.  
  563.         or, with hex,
  564.  
  565.            ix0 = $0FF7F * ix1 - ix2
  566.            iy0 = $0FF7F * iy1 - iy2
  567.  
  568.         or, in binary,
  569.  
  570.            ix0 = b0000 1111 1111 0111 1111 * ix1 - ix2
  571.            iy0 = b0000 1111 1111 0111 1111 * iy1 - iy2
  572.  
  573.         or using complementarity, i.e., $0FF7F = $10000 - $00080,
  574.  
  575.            ix0 = (ix - ix div 512) shl 1 - ix2
  576.            iy0 = (iy - iy div 512) shl 1 - iy2
  577.  
  578.                Therefore, for this case, where the operands remain 
  579.         scaled at B30, sine and cosine are generated with two shifts and 
  580.         two adds.  If TURBO or TopSpeed had a `sar' it would be used 
  581.         rather than `div'.
  582.  
  583.                There are many nearby angles with duplicate bit patterns 
  584.         and the tabulated data has been edited. There are many useful 
  585.         angles with two distinct bits, etc.  Routine CIRCDAI2 illus-
  586.         trates application for this example with difference angle scaled 
  587.  
  588.  
  589.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.         B15 and minimum distinct bit count ideas for n = 100 which corre-
  599.         sponds to a circle with radius about 1000.
  600.  
  601.  
  602.         `Minimum' Angle
  603.  
  604.                The selection of angles above was limited to 360/n and not 
  605.         many angles were found.  These angles correspond to regular 
  606.         polygons so that integral, or nearly integral, numbers of sides 
  607.         occur.  Suppose, instead, that the search is over the sine and 
  608.         cosine bit patterns themselves with only the requirement that 
  609.         sine squared plus cosine squared be about one.  The number of 
  610.         sides may not be integral but this proves not to be essential.  
  611.  
  612.                Suppose one asks whether there are such angles whose sine 
  613.         and cosine taken together contain few distinct bits.  Such angles 
  614.         permit coordinate rotations with a correspondingly small number 
  615.         of shift and add operations.
  616.  
  617.                For each scaling of the circular functions, e.g. B14, B15, 
  618.         etc., there are angles whose distinct set bit count is minimum.  
  619.         Generally, these angles change with scaling.
  620.  
  621.                Routine MINCANG searches for such angles where sine and 
  622.         cosine are scaled Bxx and produces the table below for 3 or fewer 
  623.         distinct bits.  Note that each pair has complementary angles.  
  624.         The value for 89.55238 degrees contains just one distinct bit. 
  625.         The values for 7.18076 and and 82.81936 scaled at B15 are also 
  626.         interesting because they each contain only two distinct bits.  
  627.         The first is close to 7.2 degrees or exactly 1/50 of a circle.  
  628.         Routine CIRCRAM uses this angle to draw circles.  Its utility is 
  629.         limited because fifty sides is about the right number for a 
  630.         circle with radius about 255.  Smaller circles are using too many 
  631.         sides and larger circles, not enough.  See DELTA ANGLE table 
  632.         above.
  633.  
  634.  
  635.                              MINIMUM ANGLE B14
  636.  
  637.            ==================================================
  638.                 ang      r     sin     cos   number of bits
  639.                (deg)                         sin  cos  total
  640.            --------------------------------------------------
  641.              89.10474     2   $3FFE   $0100   -1    1    2*
  642.              82.80538     2   $3F7F   $0804   -1    2    3
  643.               7.19485   254   $0804   $3F7F    2   -1    3
  644.               7.18781   254   $0802   $3F7F    2   -1    3
  645.               7.18428   254   $0801   $3F7F    2   -1    3
  646.               7.18076   255   $0800   $3F7F    1   -1    2*
  647.               3.63939   991   $0410   $3FDF    2   -1    3
  648.               3.61135  1007   $0408   $3FDF    2   -1    3
  649.               1.90275  3627   $0220   $3FF7    2   -1    3
  650.            ==================================================
  651.  
  652.  
  653.  
  654.  
  655.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                              MINIMUM ANGLE B15
  665.  
  666.            ==================================================
  667.                 ang      r     sin     cos   number of bits
  668.                (deg)                         sin  cos  total
  669.            --------------------------------------------------
  670.              89.55238     2   $7FFF   $0100    0    1    1*
  671.              89.10474     2   $7FFC   $0200   -2    1    3
  672.              88.65710     2   $7FF7   $0300   -1    2    3
  673.              82.81936     2   $7EFF   $1000   -1    1    2*
  674.              14.47751    63   $2000   $7BEF    1   -2    3
  675.               7.18428   254   $1002   $7EFF    2   -1    3
  676.               7.18252   255   $1001   $7EFF    2   -1    3
  677.               7.18076   255   $1000   $7EFF    1   -1    2*
  678.               3.61135  1007   $0810   $7FBF    2   -1    3
  679.               3.59734  1015   $0808   $7FBF    2   -1    3
  680.               1.84677  3850   $0420   $7FEF    2   -1    3
  681.            ==================================================
  682.  
  683.  
  684.                              MINIMUM ANGLE B16
  685.  
  686.            ==================================================
  687.                 ang      r     sin     cos   number of bits
  688.                (deg)                         sin  cos  total
  689.            --------------------------------------------------
  690.              89.55238     2   $FFFE   $0200   -1    1    2
  691.              82.81936     2   $FDFE   $2000   -2    1    3
  692.              75.52263     2   $F7DF   $4000   -2    1    3
  693.              14.47751    63   $4000   $F7DF    1   -2    3
  694.               7.18076   255   $2000   $FDFE    1   -2    3
  695.               3.59734  1015   $1010   $FF7F    2   -1    3
  696.               3.59033  1019   $1008   $FF7F    2   -1    3
  697.               1.81878  3970   $0820   $FFDF    2   -1    3
  698.            ==================================================
  699.  
  700.  
  701.                Routine CIRCRAM uses parameters at B15 for angle 7.18076 
  702.         and ELIPRAM uses parameters at B14 for the same angle to draw 
  703.         ellipses.  Routines with `*M*.x' names use this minimum angle 
  704.         idea.
  705.  
  706.                Note that one way of thinking about ellipses is in terms 
  707.         of two circles, viz., major and minor axes circles.  An ellipse 
  708.         can be generated by taking the x coordinate from the major circle 
  709.         and the y coordinate from the minor circle.  That is;
  710.  
  711.               2         2
  712.            cos (A) + sin (A) = 1
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.         or
  731.  
  732.             2   2       2   2
  733.            a cos (A)   b sin (A) 
  734.            --------- + --------- = 1
  735.                 2           2
  736.                a           b
  737.  
  738.         or, the usual equation of an ellipse,
  739.  
  740.             2      2
  741.            x      y
  742.            --  +  -- = 1
  743.             2      2
  744.            a      b
  745.  
  746.         where a and b are major and minor semi-axes and x = a cos(A) and 
  747.         y = b sin(A).
  748.  
  749.                Routine CIRCRAS uses 89.10474 at B15 to draw points on a 
  750.         circular constellation.  The angular step is not commensurate 
  751.         with 360 so that the pattern of points precesses slightly with 
  752.         each revolution.  This routine is included just to show what some 
  753.         of the values in these tables mean.  The algorithm for this value 
  754.         is unstable, i.e., if more and more points are drawn they no 
  755.         longer lie on a circle but spiral in or out depending upon 
  756.         effective computational modulus.  Any of the `minimum' angle 
  757.         values - incommensurate with 360 - can be applied to generate 
  758.         constellations this way.  There are similar elliptic 
  759.         constellations.
  760.  
  761.                For the elliptic routines there are drivers DEMOELIP and 
  762.         BNCHELIP to show and time the ellipse drawing routines 
  763.         distributed with this release.  See DISTRIBUTION section below.
  764.  
  765.  
  766.         `Minimum' Cosine
  767.  
  768.                Routine MINCOS tabulates rounded number of chord seg-
  769.         ments, angle, and cosine and sine for angles whose cosine bit 
  770.         pattern contains only one distinct bit.
  771.  
  772.  
  773.                             MINIMUM COSINE B14
  774.  
  775.            ==========================================================
  776.             n       ang      r     cos     sin    2*cos  nbit |nbit|
  777.                    (deg)                                 2cos  2cos
  778.            ----------------------------------------------------------
  779.              4   89.10471     2   $3FFE   $0100   $0200    1    1
  780.              4   88.20921     2   $3FF8   $0200   $0400    1    1
  781.              4   86.41668     2   $3FE0   $0400   $0800    1    1
  782.              4   82.81924     2   $3F7F   $0800   $1000    1    1
  783.              5   75.52249     2   $3DF8   $1000   $2000    1    1
  784.              6   60.00202     4   $376D   $2000   $3FFF   -1    1
  785.  
  786.  
  787.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.              6   60.00000     4   $376D   $2000   $4000    1    1
  797.              9   41.41227     8   $2A56   $3000   $5FFF   -1    1
  798.             12   28.95864    16   $1EFD   $3800   $6FFF   -1    1
  799.             18   20.36916    32   $1647   $3C00   $77FF   -1    1
  800.             25   14.36856    64   $0FE2   $3E00   $7BFF   -1    1
  801.             35   10.15172   127   $0B48   $3F00   $7DFF   -1    1
  802.             50    7.18065   255   $0800   $3F80   $7EFF   -1    1
  803.             71    5.08569   508   $05AC   $3FC0   $7F7F   -1    1
  804.            100    3.60945  1008   $0407   $3FE0   $7FBF   -1    1
  805.            140    2.57162  1986   $02DF   $3FF0   $7FDF   -1    1
  806.            195    1.84568  3855   $0210   $3FF8   $7FEF   -1    1
  807.            ==========================================================
  808.  
  809.  
  810.                             MINIMUM COSINE B15
  811.  
  812.            ==========================================================
  813.             n       ang      r     cos     sin    2*cos  nbit |nbit|
  814.                    (deg)                                 2cos  2cos
  815.            ----------------------------------------------------------
  816.              4   89.55238     2   $7FFF   $0100   $0200    1    1
  817.              4   89.10471     2   $7FFC   $0200   $0400    1    1
  818.              4   88.20921     2   $7FF0   $0400   $0800    1    1
  819.              4   86.41668     2   $7FC0   $0800   $1000    1    1
  820.              4   82.81924     2   $7EFF   $1000   $2000    1    1
  821.              5   75.52249     2   $7BEF   $2000   $4000    1    1
  822.              6   60.00101     4   $6EDA   $4000   $7FFF   -1    1
  823.              6   60.00000     4   $6EDA   $4000   $8000    1    1
  824.              9   41.41095     8   $54AB   $6000   $BFFF   -1    1
  825.             12   28.95683    16   $3DF9   $7000   $DFFF   -1    1
  826.             18   20.36665    32   $2C8C   $7800   $EFFF   -1    1
  827.             25   14.36504    64   $1FC2   $7C00   $F7FF   -1    1
  828.             35   10.14676   128   $168D   $7E00   $FBFF   -1    1
  829.             50    7.17365   255   $0FFC   $7F00   $FDFF   -1    1
  830.             71    5.07582   510   $0B53   $7F80   $FEFF   -1    1
  831.            100    3.59554  1016   $0807   $7FC0   $FF7F   -1    1
  832.            141    2.55206  2016   $05B3   $7FE0   $FFBF   -1    1
  833.            ==========================================================
  834.  
  835.  
  836.                             MINIMUM COSINE B16
  837.  
  838.            ==============================================================
  839.             n       ang      r     cos     sin      2*cos    nbit |nbit|
  840.                    (deg)                                     2cos  2cos
  841.            --------------------------------------------------------------
  842.              4   89.55238     2   $FFFE   $0200   $00000400    1    1
  843.              4   89.10471     2   $FFF8   $0400   $00000800    1    1
  844.              4   88.20921     2   $FFE0   $0800   $00001000    1    1
  845.              4   86.41668     2   $FF80   $1000   $00002000    1    1
  846.              4   82.81924     2   $FDFE   $2000   $00004000    1    1
  847.              5   75.52249     2   $F7DF   $4000   $00008000    1    1
  848.              6   60.00051     4   $DDB4   $8000   $0000FFFF   -1    1
  849.              6   60.00000     4   $DDB4   $8000   $00010000    1    1
  850.              9   41.41028     8   $A955   $C000   $00017FFF   -1    1
  851.  
  852.  
  853.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.             12   28.95593    16   $7BF0   $E000   $0001BFFF   -1    1
  863.             18   20.36539    32   $5917   $F000   $0001DFFF   -1    1
  864.             25   14.36327    64   $3F81   $F800   $0001EFFF   -1    1
  865.             35   10.14428   128   $2D17   $FC00   $0001F7FF   -1    1
  866.             50    7.17015   255   $1FF4   $FE00   $0001FBFF   -1    1
  867.             71    5.07088   511   $16A1   $FF00   $0001FDFF   -1    1
  868.            100    3.58856  1020   $1006   $FF80   $0001FEFF   -1    1
  869.            142    2.54222  2032   $0B5B   $FFC0   $0001FF7F   -1    1
  870.            ==============================================================
  871.  
  872.  
  873.                Routine CIRCDAM2 implements the algorithm for scaling 
  874.         at B15 and two times cosine equal to $FEFF with 71 segments 
  875.         corresponding to a circle with radius about 510.
  876.  
  877.                Routine CIRCDAS uses the values for 75.52249 to execute a 
  878.         difference equation approach to constellation generation where 
  879.         computation of sine or cosine requires one shift and one add.  
  880.         This selection is arbitrary and most of the entries in the table 
  881.         above will work as well or better as long as the effective step 
  882.         angle is incommensurate to 360.  All of those that this author 
  883.         has tried, for both rotation and difference angles, are unstable.
  884.  
  885.  
  886.         Delta Hyperbolic Angles
  887.  
  888.                The ideas outlined above, excepting incremental angles, 
  889.         all apply to hyperbolae.  A hyperbola cannot be said to have a 
  890.         period in the same sense that circles and ellipses can, so the 
  891.         idea of dividing infinity by n to get a step interval is not 
  892.         immediately useful.
  893.  
  894.         Given;
  895.  
  896.                2          2
  897.            cosh (A) - sinh (A) = 1
  898.  
  899.         then,
  900.  
  901.             2      2
  902.            x      y  
  903.            --  -  -- = 1 .
  904.             2      2
  905.            a      b
  906.  
  907.  
  908.                Hyperbolic coordinates are unbounded.  If display coordi-
  909.         nates are arbitrarily restriced to 16 bit 2's complement numbers 
  910.         then there is a relation between hyperbolic function argument 
  911.         step and number of steps to drive a coordinate asymptote to 
  912.         display limit, i.e., r cosh x < 32768.
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                Geometrically, the step angle is estimated from the rela-
  929.         tion:
  930.  
  931.                 dx    r + 0.5
  932.            cosh(--) = -------
  933.                  2       r
  934.  
  935.         which is approximated by,
  936.  
  937.                         1
  938.            dx = 2 sqrt( - )
  939.                         r
  940.  
  941.         much like the relations for circular functions.  The sum angle 
  942.         formula for cosh gives:
  943.  
  944.            cosh (x+dx) = cosh(x) * cosh(dx) + sinh(x) * sinh(dx)
  945.  
  946.         which can be iterated to produce the exact number of rotations 
  947.         required to reach a display limit.  An approximation is derived 
  948.         by observing that:
  949.  
  950.            cosh (x+dx) = cosh(x) (cosh(dx) + dx)
  951.  
  952.         for asymptotically large r and x.  If r = 1 then cosh(dx) = 2 so 
  953.         that:
  954.  
  955.            r cosh(x) < 16384
  956.  
  957.         is the iteration limit because the next step would produce over-
  958.         flow.  Therefore, the number of rotations can be estimated:
  959.  
  960.                           32768
  961.                       ln( ----- )
  962.                             r 
  963.            ndxe = -----------------
  964.                   ln(cosh(dx) + dx)
  965.  
  966.                Routine DELHANG computes the exact and estimated num-
  967.         ber of steps for radii from 1 to 1024 tabulated below.
  968.  
  969.  
  970.               DELTA HYPERBOLIC ANGLES
  971.  
  972.            ============================
  973.               r       dx     ndx  ndxe
  974.            ----------------------------
  975.                1    2.00000    6    5
  976.                2    1.41421    7    7
  977.                4    1.00000   10    9
  978.                8    0.70711   12   12
  979.               16    0.50000   16   15
  980.               32    0.35355   20   19
  981.               64    0.25000   25   25
  982.              128    0.17678   32   31
  983.  
  984.  
  985.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.              256    0.12500   39   38
  995.              512    0.08839   48   47
  996.             1024    0.06250   56   55
  997.            ----------------------------
  998.  
  999.  
  1000.                The number of strokes computed above is worst case and 
  1001.         necessary only to a display coordinate space scaled to 16 bits.  
  1002.         For example, a Hercules display adapter with resolution 720 x 348 
  1003.         requires, typically, 10-12 strokes per asymptote for a complete, 
  1004.         i.e., two branches or four asymptotes, display centered hyperbola.
  1005.  
  1006.                A more realistic stroke count can be estimated by requir-
  1007.         ing that the hyperbolic coordinates be bounded by offset display 
  1008.         window limits.  That is, if the conic is centered at (0,0) rather 
  1009.         than at display center then the maximum coordinate is display 
  1010.         width.  Therefore, if coordinate limit is computed:
  1011.  
  1012.            r cosh(x) <= abs(xc) + xd <= 32767
  1013.  
  1014.         where xd is display width, then stroke count is reduced.  The 
  1015.         table below shows this relation, computed by DELHANGD, for a 
  1016.         Hercules graphics adapter with xc = 360:
  1017.  
  1018.  
  1019.               DELTA HYPERBOLIC ANGLES
  1020.                 DISPLAY COORDINATES
  1021.  
  1022.            ============================
  1023.               r       dx     ndx  ndxe
  1024.            ----------------------------
  1025.                1    2.00000    4    4
  1026.                2    1.41421    5    5
  1027.                4    1.00000    7    6
  1028.                8    0.70711    8    8
  1029.               16    0.50000   10   10
  1030.               32    0.35355   12   12
  1031.               64    0.25000   15   14
  1032.              128    0.17678   16   16
  1033.              256    0.12500   17   17
  1034.              512    0.08839   16   16
  1035.             1024    0.06250    6   11
  1036.            ----------------------------
  1037.  
  1038.  
  1039.                These estimates are for an unrotated hyperbola.  The esti-
  1040.         mate for number of steps used in all hyperbolic routines is based 
  1041.         on the two dimensional extension of this idea where an effective 
  1042.         radial coordinate limit is computed from horizontal and vertical 
  1043.         coordinate limits.  There is no need to adjust dx for rounded ndx 
  1044.         because closure is not an issue.
  1045.  
  1046.                This estimate is still as much as two times too high 
  1047.         depending upon actual center and eccentricity.  
  1048.  
  1049.  
  1050.  
  1051.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.         `Minimum' Hyperbolic Angles
  1062.  
  1063.                Routine MINHANG searches the bit patterns for hyperbolic 
  1064.         sines and cosines scaled Bxx and lists those arguments for which 
  1065.         the sum of distinct set bits in sinh and cosh is less than 5.  
  1066.         Also listed is the radius for a corresponding equilateral hyper-
  1067.         bola.  Routine HYPRRAM demonstrates application of the parameters 
  1068.         for the case r equals 257.
  1069.  
  1070.  
  1071.                      MINIMUM HYPERBOLIC ANGLE B14
  1072.  
  1073.            ==================================================
  1074.                 arg      r     sinh    cosh  number of bits
  1075.                                              sinh cosh total
  1076.            --------------------------------------------------
  1077.               0.69315     8   $3000   $5000    2    2    4
  1078.               0.69310     8   $2FFF   $4FFF   -1   -2    3*
  1079.               0.69305     8   $2FFE   $4FFF   -2   -2    4
  1080.               0.24936    64   $1020   $4200    2    2    4
  1081.               0.12516   255   $0808   $4080    2    2    4
  1082.               0.12492   256   $0804   $4080    2    2    4
  1083.               0.12480   257   $0802   $4080    2    2    4
  1084.               0.12474   257   $0801   $4080    2    2    4
  1085.               0.12468   257   $0800   $4080    1    2    3*
  1086.               0.06295  1010   $0408   $4020    2    2    4
  1087.               0.06270  1017   $0404   $4020    2    2    4
  1088.               0.06258  1021   $0402   $4020    2    2    4
  1089.               0.06252  1023   $0401   $4020    2    2    4
  1090.               0.06246  1025   $0400   $4020    1    2    3*
  1091.               0.03173  3972   $0208   $4008    2    2    4
  1092.            ==================================================
  1093.  
  1094.  
  1095.                      MINIMUM HYPERBOLIC ANGLE B15
  1096.  
  1097.            ==================================================
  1098.                 arg      r     sinh    cosh  number of bits
  1099.                                              sinh cosh total
  1100.            --------------------------------------------------
  1101.               0.69315     8   $6000   $A000    2    2    4
  1102.               0.69312     8   $5FFF   $9FFF   -1   -2    3*
  1103.               0.69310     8   $5FFE   $9FFF   -2   -2    4
  1104.               0.24936    64   $2040   $8400    2    2    4
  1105.               0.12492   256   $1008   $8100    2    2    4
  1106.               0.12480   257   $1004   $8100    2    2    4
  1107.               0.06270  1017   $0808   $8040    2    2    4
  1108.               0.06258  1021   $0804   $8040    2    2    4
  1109.               0.06252  1023   $0802   $8040    2    2    4
  1110.               0.06249  1024   $0801   $8040    2    2    4
  1111.               0.06246  1025   $0800   $8040    1    2    3*
  1112.               0.03173  3972   $0410   $8010    2    2    4
  1113.            ==================================================
  1114.  
  1115.  
  1116.  
  1117.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.                        MINIMUM HYPERBOLIC ANGLE B16
  1128.  
  1129.            ======================================================
  1130.                 arg      r     sinh      cosh    number of bits
  1131.                                                  sinh cosh total
  1132.            ------------------------------------------------------
  1133.               0.69315     8   $C000   $00014000    2    2    4
  1134.               0.69313     8   $BFFF   $00013FFF   -1   -2    3*
  1135.               0.69312     8   $BFFE   $00013FFF   -2   -2    4
  1136.               0.24936    64   $4080   $00010800    2    2    4
  1137.               0.12492   256   $2010   $00010200    2    2    4
  1138.               0.06258  1021   $1008   $00010080    2    2    4
  1139.               0.06252  1023   $1004   $00010080    2    2    4
  1140.               0.06249  1024   $1002   $00010080    2    2    4
  1141.               0.06247  1025   $1001   $00010080    2    2    4
  1142.               0.06246  1025   $1000   $00010080    1    2    3*
  1143.               0.03149  4034   $0810   $00010020    2    2    4
  1144.            ======================================================
  1145.            *minima
  1146.  
  1147.  
  1148.         `Minimum' Hyperbolic Cosines
  1149.  
  1150.                The difference equations for sinh or cosh generation are 
  1151.         just like those for the circular functions with a coefficient c = 
  1152.         2 * cosh(da).
  1153.  
  1154.                Routine MINCOSH searches the interval (1.0 < cosh <= 1.25) 
  1155.         and lists the arguments whose hyperbolic cosines scaled Bxx 
  1156.         contain fewer than three distinct bits.  Routine HYPRDAM 
  1157.         implements the B16, r = 512 parameters.
  1158.  
  1159.  
  1160.                       MINIMUM HYPERBOLIC COSINE B14
  1161.  
  1162.            ======================================================
  1163.                 arg      r     sinh    cosh  2*cosh  nbit |nbit|
  1164.                                                     2cosh  2cosh
  1165.            ------------------------------------------------------
  1166.               0.69311     8   $2FFF   $5000   $9FFF   -2    2
  1167.               0.49493    16   $20FC   $4800   $9000    2    2
  1168.               0.35174    32   $16FA   $4400   $8800    2    2
  1169.               0.24935    64   $1020   $4200   $8400    2    2
  1170.               0.17655   128   $0B5C   $4100   $8200    2    2
  1171.               0.12492   256   $0804   $4080   $8100    2    2
  1172.               0.08836   512   $05AA   $4040   $8080    2    2
  1173.               0.06249  1024   $0400   $4020   $8040    2    2
  1174.               0.04419  2048   $02D4   $4010   $8020    2    2
  1175.            ======================================================
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                         MINIMUM HYPERBOLIC COSINE B15
  1193.  
  1194.            ==========================================================
  1195.                 arg      r     sinh    cosh    2*cosh    nbit |nbit|
  1196.                                                         2cosh 2cosh
  1197.            ----------------------------------------------------------
  1198.               0.69313     8   $5FFF   $A000   $00013FFF   -2    2
  1199.               0.49493    16   $41F8   $9000   $00012000    2    2
  1200.               0.35174    32   $2DF5   $8800   $00011000    2    2
  1201.               0.24935    64   $2040   $8400   $00010800    2    2
  1202.               0.17655   128   $16B7   $8200   $00010400    2    2
  1203.               0.12492   256   $1008   $8100   $00010200    2    2
  1204.               0.08836   512   $0B53   $8080   $00010100    2    2
  1205.               0.06249  1024   $0801   $8040   $00010080    2    2
  1206.               0.04419  2048   $05A9   $8020   $00010040    2    2
  1207.            ==========================================================
  1208.  
  1209.  
  1210.                             MINIMUM HYPERBOLIC COSINE B16
  1211.  
  1212.         ==============================================================
  1213.              arg      r     sinh      cosh       2*cosh   nbit |nbit|
  1214.                                                          2cosh  2cosh
  1215.         --------------------------------------------------------------
  1216.            0.69314     8   $BFFF   $00014000   $00027FFF   -2    2
  1217.            0.49493    16   $83F0   $00012000   $00024000    2    2
  1218.            0.35174    32   $5BEA   $00011000   $00022000    2    2
  1219.            0.24935    64   $4080   $00010800   $00021000    2    2
  1220.            0.17655   128   $2D6E   $00010400   $00020800    2    2
  1221.            0.12492   256   $2010   $00010200   $00020400    2    2
  1222.            0.08836   512   $16A6   $00010100   $00020200    2    2
  1223.            0.06249  1024   $1002   $00010080   $00020100    2    2
  1224.            0.04419  2048   $0B51   $00010040   $00020080    2    2
  1225.         ==============================================================
  1226.  
  1227.  
  1228.         Parabola
  1229.  
  1230.              Routines to generate parabolas are included just to cover 
  1231.         all conics.  They do not demonstrate incremental or minimum angle 
  1232.         ideas. 
  1233.  
  1234.              A parabola can be defined, among many ways, as a curve 
  1235.         equidistant between a point and a line.  That distance is usually 
  1236.         denoted by p - the parameter.  The point is called the focus and 
  1237.         the line is called the directrix.  The point on the curve midway 
  1238.         between the focus and directrix is the vertex.  If the focus is 
  1239.         at (-p/2,0) and the vertex is at (0,0) then the equation of the 
  1240.         parabola is y*y = -2*x*p.  The figure is open to the left rather 
  1241.         than open upwards and this orientation is defined, here, to be at 
  1242.         zero rotation angle.
  1243.  
  1244.              The curve can be generated by stepping the polar angle from 
  1245.         0 at the vertex to 180 at the asymptotic limit and drawing both 
  1246.         asymptotes by reflection.  The discussion regarding hyperbolic 
  1247.  
  1248.  
  1249.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.         limits also applies here and limits the polar radius to 
  1259.         abs(xf)+xd where (xf,yf) is the focus and xd is display width in 
  1260.         pixels.
  1261.  
  1262.              The step angle can be computed from the local radius of 
  1263.         curvature by evaluating da = 2.0*sqrt(1.0/R) where R is radius of 
  1264.         curvature estimated by:
  1265.                             
  1266.                         2   
  1267.                        r    3/2 
  1268.            R = p ( 1 + -- ) 
  1269.                         2
  1270.                        p
  1271.  
  1272.         where r is polar radius.  Routine PARASA generates parabolas with 
  1273.         specified focal coordinates, parameters, and rotation angles.   
  1274.         Routine DEMOPARA is a driver.  Routines ParaRA and ParaRAF 
  1275.         present floating and fixed, respectively, rotation angle 
  1276.         algorithms and routines ParaMB and ParaMBR present offset error 
  1277.         algortihms.  
  1278.  
  1279.  
  1280.         Offset Error Methods
  1281.  
  1282.                Let a circle be defined:
  1283.  
  1284.             2    2    2
  1285.            x  + y  = r
  1286.  
  1287.         and pick a point, say, (ix,iy).  If that point is picked to 
  1288.         satisfy the equation then the error at that point can be taken to 
  1289.         be zero.  If a positive step of one unit in x is taken then the 
  1290.         equation becomes:
  1291.  
  1292.                  2     2    2
  1293.            (ix+1)  + iy  = r  + ie,
  1294.  
  1295.         or
  1296.               2                 2    2
  1297.            (ix  + 2 ix + 1) + iy  = r  + ie,
  1298.  
  1299.         where ie is the offset error for a unit step in x:
  1300.  
  1301.            +x:   ie = 2 ix + 1.
  1302.  
  1303.                Similarly, for a negative step in x or steps in y:
  1304.  
  1305.            -x:   ie = -2 ix + 1,
  1306.            +y:   ie = 2 iy + 1,
  1307.            -y:   ie = -2 iy + 1.  
  1308.  
  1309.                The idea of the offset error method is to pick a sequence 
  1310.         of x and y steps to attempt to reduce the cumulative offset 
  1311.         error.  For example, take the starting point for a circle 
  1312.         at (0,r) and step positive in x and negative in y until x = y. 
  1313.  
  1314.  
  1315.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.         This segment is one octant of a circle.  Copying this segment 
  1325.         with suitable reflections produces a complete circle.  Obviously, the 
  1326.         starting point can be anywhere on the circle with self consistent 
  1327.         arrangements for stepping and copying to produce a complete 
  1328.         figure.  The algorithm can be outlined:
  1329.            
  1330.            ix = 0
  1331.            iy = r
  1332.            ie = 0
  1333.            while ix < iy do begin
  1334.               ie = ie + 2*ix + 1
  1335.               ix = ix + 1
  1336.               if ie > 0 then begin
  1337.                  ie = ie - 2*iy + 1
  1338.                  iy = iy - 1
  1339.               end
  1340.               pixel(ix,iy)
  1341.               ...
  1342.            end 
  1343.  
  1344.         where the copying is denoted by the ellipsis.
  1345.  
  1346.               With suitable consideration of quadrant and octant points 
  1347.         this is Bresenham's circle algorithm.  In a certain sense, the 
  1348.         offset error is the error in area of the figure.  If another 
  1349.         property like radius or curvature is used then another kind of 
  1350.         offset error algorithm results.  In two dimensions area offset 
  1351.         error reduction produces esthetically satisfactory results.  
  1352.         Offset error methods are not restricted to conics or to two 
  1353.         dimensions.
  1354.  
  1355.                There are many modifications to this algorithm.  For 
  1356.         example, if a step in y is taken only if the absolute error is 
  1357.         reduced then the algorithm appears:
  1358.  
  1359.            ix = 0
  1360.            iy = r
  1361.            ie = 0
  1362.            while ix < iy do begin
  1363.               ie = ie + 2*ix + 1
  1364.               ix = ix + 1
  1365.               iey = ie - 2*iy + 1
  1366.               if abs(ie) > abs(iey) then begin
  1367.                  ie = iey
  1368.                  iy = iy - 1
  1369.               end
  1370.               pixel(ix,iy)
  1371.               ...
  1372.            end 
  1373.  
  1374.                This algorithm is trying to minimize the offset error.  If 
  1375.         aspect ratio is considered then the equation becomes:
  1376.  
  1377.             2    2 2    2
  1378.            x  + y c  = r
  1379.  
  1380.  
  1381.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.         where c is a vertical scale factor.  This aspect ratio parameter 
  1392.         is computed from the effective display dimensions and resolutions.
  1393.         A standard broadcast video monitor has an aspect of 4 units 
  1394.         horizontally and 3 units vertically.  For a Hercules graphics 
  1395.         adaptor the resolutions are 720 by 348.  Ideally, such an adaptor 
  1396.         driving such a monitor would produce vertical pixel distances of 
  1397.         3/347 and horizontal distances of 4/719.  The parameter c would 
  1398.         be:
  1399.  
  1400.            c = 3/347 / 4/719 = 1.55...
  1401.  
  1402.                For computer displays an effective aspect of 3 to 2 is 
  1403.         more common with:
  1404.  
  1405.            c = 2/347 / 3/719 = 1.38...,
  1406.  
  1407.               The wrong value makes circles into ellipses.  The particu-
  1408.         lar monitor on which this writeup is prepared has an actual c = 
  1409.         1.43.  Let w denote width in pixels and h denote height in 
  1410.         pixels.  Then:
  1411.  
  1412.            c = 2/(h-1) / 3/(w-1),
  1413.  
  1414.         and ignore the -1 terms:
  1415.  
  1416.            c = 2/h / 3/w.
  1417.  
  1418.                The circle equation may be written - by clearing the 
  1419.         fractions:
  1420.  
  1421.                   2          2        2
  1422.            (3h ix)  + (2w iy)  = (3h r)
  1423.  
  1424.         and the relevant unit offset errors are:
  1425.  
  1426.                                    2
  1427.            +x:   ie = (2 ix + 1) 9h ,
  1428.  
  1429.                                     2
  1430.            -y:   ie = -(2 iy - 1) 4w ,
  1431.  
  1432.         and the algorithm becomes:
  1433.  
  1434.            ix = 0
  1435.            iy = r
  1436.            px2 = sqr(3h)
  1437.            py2 = sqr(2w)
  1438.            ie = 0
  1439.            while ix*px2 < iy*py2 do begin
  1440.               ie = ie + (2*ix + 1) px2
  1441.               ix = ix + 1
  1442.               iey = ie - (2*iy - 1) py2
  1443.               if abs(ie) > abs(iey) then begin
  1444.                  ie = iey
  1445.  
  1446.  
  1447.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                  iy = iy - 1
  1457.               end
  1458.               pixel(ix,iy)
  1459.               ...
  1460.            end 
  1461.            while iy > 0 do begin
  1462.               ie = ie - (2*iy - 1) dey2
  1463.               iy = iy - 1
  1464.               iex = ie + (2*ix + 1) dex2
  1465.               if abs(ie) > abs(iex) then begin
  1466.                  ie = iex
  1467.                  ix = ix + 1
  1468.               end
  1469.               pixel(ix,iy)
  1470.               ...
  1471.            end 
  1472.  
  1473.         where a couple things have changed.  First, octant symmetry is 
  1474.         lost and a quadrant is drawn in two segments with stepping in x 
  1475.         dominating the first loop and stepping in y dominating the 
  1476.         second.  The changeover in stepping in x to stepping in y is at 
  1477.         the point where the absolute slope is about one.  The ellipsis 
  1478.         denote quadrant copying operations.  This algorithm is called 
  1479.         modified Bresenham.  
  1480.  
  1481.                Second, the loop control condition for the second segment, 
  1482.         viz. iy > 0, is correct but misleading.  Area is invariant - not 
  1483.         coordinate.  The loop control should be iy*py2, i.e. the area 
  1484.         weighted coordinate.  Note the loop control condition for the 
  1485.         first segment.  If the figure is drawn with the condition ix < iy
  1486.         then something looking more like sixteen sided polygons appears.
  1487.  
  1488.            Let the equation for an ellipse be written:
  1489.  
  1490.             2    2
  1491.            u  + v 
  1492.            --   --  =  1
  1493.             2    2
  1494.            a    b
  1495.  
  1496.         and suppose a coordinate rotation with equations:
  1497.  
  1498.            u = x cos(A) + y c sin(A)
  1499.  
  1500.            v = -x sin(A) + y c cos(A)
  1501.  
  1502.         where A is rotation angle an c is the vertical scale factor.  
  1503.         Substituting, expanding, and clearing fractions produces the 
  1504.         equation:
  1505.  
  1506.             2    2  2   2       2   2
  1507.            x (3h) [b cos (A) + a sin (A)] +
  1508.  
  1509.                                 2    2
  1510.               2 x y (3h) (2w) (b  - a ) sin(A) cos(A) +
  1511.  
  1512.  
  1513.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.                   2    2  2   2       2   2        2 2    2
  1524.                  y (2w) [b sin (A) + a cos (A)] = a b (3h)
  1525.  
  1526.  
  1527.                Offsetting x by one produces an error offset:
  1528.  
  1529.                                 2  2   2       2   2
  1530.            +x:  ie = (2x+1) (3h) [b cos (A) + a sin (A)] +
  1531.  
  1532.                                       2    2
  1533.                       2 y (3h) (2w) (b  - a ) sin(A) cos(A)
  1534.  
  1535.         with similar expressions for negative offset in x and offsets in 
  1536.         y.  These expressions are only slightly more complicated than 
  1537.         those for a circle.  Note that the coefficients are constants:
  1538.          
  1539.            +x:  ie = (2x+1) pxx + 2 y pxy
  1540.            -x:  ie = -(2x-1) pxx - 2 y pxy
  1541.            +y:  ie = (2y+1) pyy + 2 x pxy
  1542.            -y:  ie = -(2y-1) pyy - 2 x pxy  
  1543.  
  1544.                If the point on a ellipse where plus y is an extremum is 
  1545.         taken as a starting point then an ellipse may be produced by four 
  1546.         segments and semi-elliptic reflection.  The control outline of 
  1547.         this algorithm is:
  1548.  
  1549.                                         initialize
  1550.            ix = ix0
  1551.            iy = iy0
  1552.            ie = 0
  1553.                                         step clockwise
  1554.            while ... do  begin
  1555.               ix = ix + 1
  1556.               if abs(ie) > abs(iey) then begin
  1557.                  iy = iy - 1
  1558.               end
  1559.            end
  1560.            while ... do begin
  1561.               iy = iy - 1
  1562.               if abs(ie) > abs(iex) then begin
  1563.                  ix = ix + 1
  1564.               end
  1565.            end
  1566.                                         reinitialize
  1567.            ix = ix0
  1568.            iy = iy0
  1569.            ie = 0
  1570.                                         step counter-clockwise
  1571.            while ... do  begin
  1572.               ix = ix - 1
  1573.               if abs(ie) > abs(iey) then begin
  1574.                  iy = iy - 1
  1575.               end
  1576.            end
  1577.  
  1578.  
  1579.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.            while ... do begin
  1589.               iy = iy - 1
  1590.               if abs(ie) > abs(iex) then begin
  1591.                  ix = ix - 1
  1592.               end
  1593.            end
  1594.  
  1595.         where the operations to compute initial coordinates, offset 
  1596.         errors and increments, turning points, and plot are omitted.  
  1597.         This algorithm is modified Bresenham with rotation and routines 
  1598.         named `*MBR*.x' apply it, e.g. ElipMBR in Ellipse.MOD.  Obvious-
  1599.         ly, there is a structurally identical algorithm which starts at 
  1600.         an extremum in x with the roles of ix and iy interchanged.
  1601.  
  1602.                Similar logic is applied to produce parabolas, cf. 
  1603.         PARAMBR.PAS.  Rotated hyperbolae are generated by using a vertex 
  1604.         as starting point rather than an extremum point which may be at 
  1605.         infinity.  This requires up to three rather that two segments per 
  1606.         asymptote, cf. HYPRMBR.PAS or procedure HyprMBR in Hyprbola.MOD.
  1607.  
  1608.                Note that there is nothing that requires offset error to 
  1609.         be computed fixed point.  Also, for TURBO, a floating point 
  1610.         version of ELIPMBR is somewhat faster - if a coprocessor is 
  1611.         present;
  1612.  
  1613.  
  1614.                 ---------------------------------------------------
  1615.                                    TURBO Pascal   TopSpeed Modula-2
  1616.                 Routine   Mode     Timing (sec)      Timing (sec)
  1617.                                     w/     w/o        w/     w/o
  1618.                 ---------------------------------------------------
  1619.                 ELIPMBR   Fix      0.334  0.304      0.150  0.199
  1620.                 ELIPMBR   Float    0.249  0.547      0.262  2.352
  1621.                 ---------------------------------------------------
  1622.  
  1623.  
  1624.               It would diminish the scaling problem for small parameter 
  1625.         figures to compute it floating point.  For example, an ellipse 
  1626.         with parameters a = 10 and b = 2 is unsatisfactory at most 
  1627.         rotation angles.  Roughly speaking, this problem arises because 
  1628.         the projection of small parameter radii upon the lower resolution 
  1629.         vertical axis is less than one vertical pixel unit which is 
  1630.         typically about one and one half horizontal pixels.  Parameter 
  1631.         `s' in parabolic and hyperbolic `*MBR.x' routines tries to extend 
  1632.         the useful parameter range.  
  1633.  
  1634.  
  1635.         Radius Scaling
  1636.  
  1637.                Fixed point arithmetic requires that operands be scaled.  
  1638.         Scaling depends on word length and desired or required operand 
  1639.         range.  For example, if radii 0-511 are desired then scaling at 
  1640.         B6 is possible for coordinate variables encoded using 16 bit 
  1641.         integers or B22 using 32 bit integers.
  1642.  
  1643.  
  1644.  
  1645.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.         Radius Offset
  1656.  
  1657.                The inscribed polygon is required to have a chord-tangent 
  1658.         distance not greater than 0.5.  But the ideal and chord circle 
  1659.         must both be plotted on a discrete grid.  If the ideal discrete 
  1660.         circle is taken to be that produced by Bresenham circle then it 
  1661.         is possible to consider offsetting the chord circle radius to get 
  1662.         closer agreement.  Routine DFCTCIRC displays a stroke circle, 
  1663.         clears pixels on the corresponding Bresenham circle, and counts 
  1664.         the remaining pixels.  This procedure is performed for radius 
  1665.         offsets from 0.25 to 0.75 in steps of about 0.031.
  1666.  
  1667.                For circles with radii 100 and 200 using routine CIRCRA 
  1668.         the results are:
  1669.  
  1670.  
  1671.                    DEFECT COUNT VRS. OFFSET
  1672.  
  1673.            =========================================
  1674.                                r = 100     r = 200
  1675.             offset   offset   number of   number of
  1676.              fixed    float    pixels      pixels
  1677.            -----------------------------------------
  1678.              16        0.25      124       472
  1679.              18        0.28      124       460
  1680.              20        0.31      104       406
  1681.              22        0.34      104*      406
  1682.              24        0.38      104*      406
  1683.              26        0.41      104       406
  1684.              28        0.44      148       406
  1685.              30        0.47      148       348
  1686.              32        0.50      148       268
  1687.              34        0.53      178       254*
  1688.              36        0.56      178       312
  1689.              38        0.59      178       312
  1690.              40        0.63      200       274
  1691.              42        0.66      200       368
  1692.              44        0.69      212       378
  1693.              46        0.72      212       424
  1694.              48        0.75      212       424 
  1695.            =========================================
  1696.            *minima
  1697.  
  1698.  
  1699.                This table suggests an offset of 0.3-0.5 for floating 
  1700.         point generators.  In the algorithms using floating point to 
  1701.         generate coordinates an offset of 0.5 will generally be used, 
  1702.         e.g. CIRCRA.
  1703.  
  1704.                If rotation angle arithmetic is done fixed point then 
  1705.         there is interaction between scaling, rounding, and offset, and 
  1706.         resulting closure, overflow, and defect count.
  1707.  
  1708.  
  1709.  
  1710.  
  1711.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.             Step variables may be truncated or rounded and display 
  1721.         variables may be truncated or rounded;
  1722.  
  1723.  
  1724.                ROUNDING STRATEGIES
  1725.  
  1726.            ============================
  1727.             case    step      display
  1728.                   variables  variables
  1729.            ----------------------------
  1730.              1     round       round
  1731.              2     round      truncate
  1732.              3    truncate     round
  1733.              4    truncate    truncate
  1734.            ============================
  1735.  
  1736.  
  1737.                Truncation of display variables, i.e. cases 2 and 4, 
  1738.         produces large defect counts for either float or fixed 
  1739.         arithmetic.
  1740.  
  1741.                For case 1, with both step and display rounding, the 
  1742.         relation between offset scaled B6 and defect counts for radii 100 
  1743.         and 200 are tabulated below.  Routine DFCTCIRC using CIRCRAF4 
  1744.         with step and display variable rounding enabled produces these 
  1745.         counts.
  1746.  
  1747.  
  1748.                    DEFECT COUNT VRS. OFFSET
  1749.  
  1750.            =========================================
  1751.                                r = 100     r = 200
  1752.             offset   offset   number of   number of
  1753.              fixed    float    pixels      pixels
  1754.            -----------------------------------------
  1755.              16        0.25      124       460
  1756.              18        0.28      124       460
  1757.              20        0.31      104       406
  1758.              22        0.34      104*      406
  1759.              24        0.38      104*      406
  1760.              26        0.41      104       406
  1761.              28        0.44      148       406
  1762.              30        0.47      148       348
  1763.              32        0.50      148       268*
  1764.              34        0.53      148       268*
  1765.              36        0.56      148       270
  1766.              38        0.59      148       270
  1767.              40        0.63      170       326
  1768.              42        0.66      170       326
  1769.              44        0.69      182       382
  1770.              46        0.72      182       382
  1771.              48        0.75      182       382 
  1772.            =========================================
  1773.            *minima
  1774.  
  1775.  
  1776.  
  1777.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.         where the minimum for r = 100 is at 22-24 or about 0.34-0.38 
  1788.         scaled B6, and for r = 200 it is at 32-34 or about 0.50-0.53.
  1789.  
  1790.                This means that the radius offsets are essentially the 
  1791.         same for floating point and fixed point arithmetic - but that 
  1792.         there is a radius dependence.
  1793.  
  1794.  
  1795.         Radius Constraint
  1796.  
  1797.                Using fixed point arithmetic there is a problem with 
  1798.         closure and overflow.  That is, a complete circle produced by 
  1799.         rotation of coordinates may not close, or worse, arithmetic 
  1800.         overflow due to roundoff accuulation occurs.  Failure to close 
  1801.         produces leaks on flood fill while overflow both leaks and pro-
  1802.         duces spurious graphics lines.
  1803.  
  1804.                For each algorithm and each implementation it is necessary 
  1805.         to test for closure and overflow.  Routine LEAKCRAF illustrates 
  1806.         this test specifically instrumented for a fixed point rotation 
  1807.         angle algorithm.  The test is run for the same range of offsets 
  1808.         as that used in DFCTCIRC and radii from 500 through 511 are 
  1809.         tested because it is only at the limits of the scaling range that 
  1810.         this problem arises.
  1811.  
  1812.  
  1813.                   LEAK AND OVERFLOW
  1814.  
  1815.            ===============================
  1816.               offset     leaks   overflow
  1817.            FIX   FLOAT
  1818.            -------------------------------
  1819.             16    0.25     0        0
  1820.             18    0.28     0        1
  1821.             20    0.31     0        1
  1822.             22    0.34     0        1
  1823.             24    0.38     0        1
  1824.             26    0.41     0        1
  1825.             28    0.44     0        1
  1826.             30    0.47     1        1
  1827.             32    0.50     0        0
  1828.             34    0.53     0        0
  1829.             36    0.56     1        0
  1830.             38    0.59     1        1
  1831.             40    0.63     1        1
  1832.             42    0.66     1        1
  1833.             44    0.69     1        1
  1834.             46    0.72     0        1
  1835.             48    0.75     0        1
  1836.            ===============================
  1837.  
  1838.  
  1839.                The earlier defect testing suggested fixed point offset of 
  1840.         32 at B6 or 0.5 floating point.  There are no leaks or overflow 
  1841.  
  1842.  
  1843.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.         for this selection for this algorithm and implementation.  The 
  1853.         tables below show a radius parameter constraint when the above 
  1854.         testing produced leak or overflow.  For example, routine ELIPDAI 
  1855.         which uses the difference angle algorithm for increment angle at 
  1856.         B15 and n = 50 is restricted to major and minor radii less than 
  1857.         508.
  1858.  
  1859.                The leak problem can be overcome by forcing closure on 
  1860.         starting point - with or without symmetry - but the overflow 
  1861.         problem can be best overcome by restricting radii.
  1862.  
  1863.                The rounding strategies noted above interact with closure 
  1864.         and overflow.  For each routine there is a possibility of round-
  1865.         ing or truncating coordinate or display variables.  Display vari-
  1866.         able truncation aggravates the bumpy appearance of stroked fig-
  1867.         ures at low resolution or small radii.  Truncation rather than 
  1868.         rounding of coordinate variables produces slightly asymmetric 
  1869.         figures but can solve the overflow problem.  This is an interest-
  1870.         ing problem pending availability of shift arithmetic right imple-
  1871.         mentations because the rounding would be asymmetric.
  1872.  
  1873.                The discussion above about restricting radii to something 
  1874.         less than 512 rather than 512 is for a worst case where the 
  1875.         algorithm generates chord coordinates for a full circle.  If 
  1876.         semi-circular, quadrant, or octant symmetry is exploited, then 
  1877.         overflow does not occur.
  1878.  
  1879.                Further, there are several cases where closure fails with-
  1880.         out overflow for specified radius range or where overflow occurs 
  1881.         on final stroke.  For those cases a final closing stroke can be 
  1882.         drawn to close the figure rather than computing a final stroke.
  1883.  
  1884.  
  1885.         USAGE
  1886.         =====
  1887.  
  1888.                TURBO drivers have an include header with all but one of 
  1889.         the routines commented out.  For example DEMOCIRC begins:
  1890.  
  1891.            ...
  1892.            {-$I circmb.pas }
  1893.            ... 
  1894.            {$I circra.pas }
  1895.            ...
  1896.            {-$I circras.pas }
  1897.            ...
  1898.  
  1899.         where CIRCRA is selected.  Compile and execute the driver with 
  1900.         the appropriate routine include enabled.
  1901.  
  1902.                Each routine for a particular kind of figure has the same 
  1903.         procedure name.  For example, circle routines are declared with 
  1904.         the name StrokeCircle independent of whether they are stroke.
  1905.  
  1906.                TopSpeed drivers are organized with all the procedures in 
  1907.  
  1908.  
  1909.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.         one module and each procedure is distinctly named.  `Make' the 
  1919.         driver and execute it with a command line argument specifying the 
  1920.         desired routine.  Remember to force initialization of the 
  1921.         appropriate graphics driver - all routines default to InitHerc.  
  1922.         For example: 
  1923.  
  1924.            bnchcirc circmb 
  1925.  
  1926.         would perform and report timing estimates for routine CircMB.  
  1927.  
  1928.                Note that TopSpeed requires that decimal numbers be 
  1929.         entered with decimal points and fractions.  That is, 30 # 30.0.
  1930.  
  1931.  
  1932.         PARAMETERS
  1933.         ==========
  1934.  
  1935.                                 POLYGON ROUTINES
  1936.  
  1937.               =====================================================
  1938.               Routine   Mode           Parameters        Constraint
  1939.                                    n   sin   cos   2*cos
  1940.               -----------------------------------------------------
  1941.               POLYRA    FLT      
  1942.               POLYRAF   FIX                               r<512
  1943.               POLYDA    FLT      
  1944.               POLYDAF   FIX                               r<511
  1945.               -----------------------------------------------------
  1946.  
  1947.  
  1948.                                  CIRCLE ROUTINES
  1949.  
  1950.               =====================================================
  1951.               Routine   Mode           Parameters        Constraint
  1952.                                    n   sin   cos   2*cos
  1953.               -----------------------------------------------------
  1954.               CIRCDA2   FLT      
  1955.               CIRCDAF   FIX                               r<510
  1956.               CIRCDAI   FIX B16    71 $169B $FF00 $1FDFF  r<511
  1957.               CIRCDAI2  FIX B15   100 $080F $7FBF  $FF7F  r<511
  1958.               CIRCDAM2  FIX B15    71 $0B53 $7F80  $FEFF  r<511
  1959.               CIRCDAS   FIX B15       $7BEF $2000  $4000  r<512
  1960.               CIRCRA    FLT      
  1961.               CIRCRAF4  FIX                               r<512
  1962.               CIRCRAI2  FIX B15   100 $080A $7FBF         r<511
  1963.               CIRCRAIR  FIX B14    50 $0805 $3F7F         r<512
  1964.               CIRCRAM   FIX B15    50 $1000 $7EFF         r<510 
  1965.               CIRCRAS   FIX B15       $7EFF $1000         r<504
  1966.               -----------------------------------------------------
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                                 ELLIPSE ROUTINES
  1985.  
  1986.               =====================================================
  1987.               Routine   Mode           Parameters        Constraint
  1988.                                    n   sin   cos   2*cos
  1989.               -----------------------------------------------------
  1990.               ELIPDA2   FLT      
  1991.               ELIPDAF   FIX                               r<510
  1992.               ELIPDAI   FIX B15   100 $080F $7F8F  $FF7F  r<508
  1993.               ELIPDAM   FIX B16    50 $1FF4 $FE00 $1FBFF  r<512
  1994.               ELIPRA    FLT      
  1995.               ELIPRA2   FLT      
  1996.               ELIPRAF   FIX                               r<511
  1997.               ELIPRAF2  FIX                               r<511
  1998.               ELIPRAI2  FIX B14    50 $0805 $3F7F         r<510
  1999.               ELIPRAM   FIX B14    50 $0800 $3F7F         r<511
  2000.               -----------------------------------------------------
  2001.  
  2002.  
  2003.                                 PARABOLA ROUTINES
  2004.  
  2005.               =====================================================
  2006.               Routine   Mode           Parameters        Constraint
  2007.                                    n   sin   cos   2*cos
  2008.               -----------------------------------------------------
  2009.               PARARA    FLT      
  2010.               PARARAF   FIX                               r<511
  2011.               -----------------------------------------------------
  2012.  
  2013.  
  2014.                                HYPERBOLA ROUTINES
  2015.  
  2016.               =====================================================
  2017.               Routine   Mode           Parameters        Constraint
  2018.                                    n   sinh  cosh  2*cosh
  2019.               -----------------------------------------------------
  2020.               HYPRDA    FLT      
  2021.               HYPRDAF   FIX      
  2022.               HYPRDAM   FIX B16       $16A6 $10100 $20200 
  2023.               HYPRDAMG  FIX B16       $2010 $10200 $20400  
  2024.                (SAR)     "   "          "      "      "
  2025.               HYPRRA    FLT      
  2026.               HYPRRAF   FIX      
  2027.               HYPRRAM   FIX B14       $0800  $4080         
  2028.               -----------------------------------------------------
  2029.  
  2030.  
  2031.         PERFORMANCE
  2032.         ===========
  2033.  
  2034.                All timings for both TURBO Pascal 4.0 (c) and TopSpeed 
  2035.         Modula-2 1.14 (c) are on an 8MHz 8086/8087 driving a Hercules  
  2036.         graphics adapter with the usual 720x348 resolution.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                Times are average time per figure for a more-or-less 
  2051.         random parameter selection.  For example, TopSpeed's GRAPH 
  2052.         Ellipse routine exercised by BnchElip produced a set of trials;
  2053.         0.150, 0.153, 0.144, 0.137, 0.145, 0.138, 0.147, 0.152, 0.143, 
  2054.         0.138, 0.147, and 0.139.  This sequence has a mean of 0.144 so 
  2055.         that plus or minus ten percent of the timing numbers is not 
  2056.         significant.
  2057.  
  2058.               Comparison numbers are shown for TURBO's BGI and TopSpeed's 
  2059.         GRAPH circle and ellipse routines.  BGI circles correct aspect - 
  2060.         GRAPH circles don't.  
  2061.  
  2062.                The differences in timing between Versions 1.0 and 1.1 
  2063.         arises mostly because the centers are randomized for 1.1 while 
  2064.         they are screen centered for 1.0.  Remember to disable compiler 
  2065.         check code generation, i.e. no stack checking, I/O errors, etc., 
  2066.         - makes about ten percent difference.
  2067.  
  2068.  
  2069.                                 POLYGON ROUTINES
  2070.  
  2071.                 ===================================================
  2072.                                    TURBO Pascal   TopSpeed Modula-2
  2073.                 Routine   Mode     Timing (sec)      Timing (sec)
  2074.                                     w/     w/o        w/     w/o
  2075.                 ---------------------------------------------------
  2076.                 POLYRA    FLT      0.076  0.177      0.119  0.220
  2077.                 POLYRAF   FIX      0.089  0.118      0.115  0.176
  2078.                 POLYDA    FLT      0.074  0.158      0.118  0.258
  2079.                 POLYDAF   FIX      0.082  0.135      0.120  0.176
  2080.                 ---------------------------------------------------
  2081.  
  2082.  
  2083.                                  CIRCLE ROUTINES
  2084.  
  2085.                 ===================================================
  2086.                                    TURBO Pascal   TopSpeed Modula-2
  2087.                 Routine   Mode     Timing (sec)      Timing (sec)
  2088.                                     w/     w/o        w/     w/o
  2089.                 ---------------------------------------------------
  2090.                 Circle             0.381  0.359      0.073  0.053
  2091.                 CIRCMB             0.249  0.280      0.098  0.080
  2092.                 CIRCDA2   FLT      0.086  0.153      0.086  0.210
  2093.                 CIRCDAF   FIX      0.119  0.134      0.110  0.127
  2094.                 CIRCDAI   FIX      0.256  0.253      0.154  0.126
  2095.                 CIRCDAI2  FIX      0.234  0.214      0.143  0.118
  2096.                 CIRCDAM2  FIX      0.177  0.163      0.121  0.097
  2097.                 CIRCDAS   FIX      0.433  0.394      0.074  0.069
  2098.                 CIRCRA    FLT      0.099  0.280      0.097  0.418
  2099.                 CIRCRAF4  FIX      0.086  0.108      0.083  0.108
  2100.                 CIRCRAI2  FIX      0.164  0.171      0.152  0.120
  2101.                 CIRCRAIR  FIX      0.236  0.224      0.112  0.101
  2102.                 CIRCRAM   FIX      0.263  0.270      0.134  0.116   
  2103.                 CIRCRAS   FIX      0.671  0.650      0.111  0.097
  2104.                 ---------------------------------------------------
  2105.  
  2106.  
  2107.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                                 ELLIPSE ROUTINES
  2117.  
  2118.                 ===================================================
  2119.                                    TURBO Pascal   TopSpeed Modula-2
  2120.                 Routine   Mode     Timing (sec)      Timing (sec)
  2121.                                     w/     w/o        w/     w/o
  2122.                 ---------------------------------------------------
  2123.                 Ellipse            0.316  0.334      0.150  0.101
  2124.                 ELIPMB             0.218  0.293      0.146  0.126
  2125.                 ELIPMBR            0.281  0.304      0.163  0.199
  2126.                 ELIPDA2   FLT      0.110  0.265      0.143  0.459
  2127.                 ELIPDAF   FIX      0.160  0.175      0.187  0.215
  2128.                 ELIPDAI   FIX      0.505  0.466      0.310  0.252
  2129.                 ELIPDAM   FIX      0.277  0.253      0.223  0.186
  2130.                 ELIPRA    FLT      0.140  0.511      0.182  0.845
  2131.                 ELIPRA2   FLT      0.105  0.282      0.157  0.527
  2132.                 ELIPRAF   FIX      0.175  0.186      0.207  0.225
  2133.                 ELIPRAF2  FIX      0.120  0.154      0.182  0.203
  2134.                 ELIPRAI2  FIX      0.135  0.150      0.191  0.165
  2135.                 ELIPRAM   FIX      0.308  0.302      0.210  0.190
  2136.                 ---------------------------------------------------
  2137.  
  2138.  
  2139.                                 PARABOLA ROUTINES
  2140.  
  2141.                 ===================================================
  2142.                                    TURBO Pascal   TopSpeed Modula-2
  2143.                 Routine   Mode     Timing (sec)      Timing (sec)
  2144.                                     w/     w/o        w/     w/o
  2145.                 ---------------------------------------------------
  2146.                 PARAMB             0.337  0.377      0.163  0.146
  2147.                 PARAMBR            0.410  0.642      0.272  0.299
  2148.                 PARARA    FLT      0.136  0.530      0.216  1.052
  2149.                 PARARAF   FIX      0.229  0.259      0.253  0.274
  2150.                 ---------------------------------------------------
  2151.  
  2152.  
  2153.                                HYPERBOLA ROUTINES
  2154.  
  2155.                 ===================================================
  2156.                                    TURBO Pascal   TopSpeed Modula-2
  2157.                 Routine   Mode     Timing (sec)      Timing (sec)
  2158.                                     w/     w/o        w/     w/o
  2159.                 ---------------------------------------------------
  2160.                 HYPRMB             0.332  0.400      0.172  0.158
  2161.                 HYPRMBR            0.376  0.466      0.259  0.272
  2162.                 HYPRDA    FLT      0.087  0.276      0.197  0.504
  2163.                 HYPRDAF   FIX      0.097  0.185      0.226  0.248
  2164.                 HYPRDAM   FIX      0.156  0.227      0.248  0.250
  2165.                 HYPRDAMG  FIX      0.148  0.198      0.220  0.229
  2166.                  (SAR)             0.109  0.151      0.207
  2167.                 HYPRRA    FLT      0.087  0.338      0.218  0.585
  2168.                 HYPRRAF   FIX      0.107  0.202      0.227  0.247
  2169.                 HYPRRAM   FIX      0.209  0.272      0.267  0.228
  2170.                 ---------------------------------------------------
  2171.  
  2172.  
  2173.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.         DISTRIBUTION
  2185.         ============
  2186.  
  2187.                Below are listed the files and functions with some com-
  2188.         ments and performance parameters that are distributed with this 
  2189.         release.
  2190.  
  2191.  
  2192.                 FILENAME                DESCRIPTION
  2193.                 --------                ----------- 
  2194.  
  2195.         TURBO          TopSpeed 
  2196.         Pascal         Modula-2
  2197.         CNC11TP        CNC11TM   
  2198.  
  2199.         CONIC.DOC      CONIC.DOC        This write-up.
  2200.  
  2201.         DELCANG        n/a              Delta circular angle.
  2202.         INCCANG        n/a              Incremental angle.
  2203.         INCCOS         n/a              Incremental cosine.
  2204.         MINCANG        n/a              Minimum angle.
  2205.         MINCOS         n/a              Minimum cosine.
  2206.         DELHANG        n/a              Delta hyperbolic angle.
  2207.         DELHANGD       n/a              Delta hyperbolic angle - display. 
  2208.         MINHANG        n/a              Minimum hyperbolic angle.
  2209.         MINCOSH        n/a              Minimum hyperbolic cosine.  
  2210.  
  2211.         CONIC          MathFun          Utility routines.
  2212.         n/a            GraphFun         Utility routine.
  2213.         n/a            Timing           Utility routine.
  2214.  
  2215.         Polygon Routines
  2216.  
  2217.         DEMOPOLY       DemoPoly         Demonstrate polygon routines.
  2218.         BNCHPOLY       BnchPoly         Timing.
  2219.  
  2220.         POLYRA         PolyRA
  2221.         POLYRAF        PolyRAF
  2222.         POLYDA         PolyDA
  2223.         POLYDAF        PolyDAF
  2224.  
  2225.         Circle Routines
  2226.  
  2227.         DEMOCIRC       DemoCirc         Demonstrate circle routines.
  2228.         BNCHCIRC       BnchCirc         Timing.
  2229.         DFCTCIRC       DfctCirc         Geometric comparison.
  2230.         LEAKCRAF       LeakCRAF         Closure and overflow.
  2231.  
  2232.         CIRCMB         CircMB
  2233.         CIRCDA2        CircDA2
  2234.         CIRCDAF        CircDAF
  2235.         CIRCDAI        CircDAI
  2236.         CIRCDAI2       CircDAI2
  2237.  
  2238.  
  2239.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.         CIRCDAM2       CircDAM2
  2249.         CIRCDAS        CircDAS
  2250.         CIRCRA         CircRA
  2251.         CIRCRAF4       CircRAF4
  2252.         CIRCRAI2       CircRAI2
  2253.         CIRCRAIR       CircRAIR
  2254.         CIRCRAM        CircRAM
  2255.         CIRCRAS        CircRAS
  2256.  
  2257.         Ellipse Routines
  2258.  
  2259.         DEMOELIP       DemoElip         Demonstrate ellipse routines.
  2260.         BNCHELIP       BnchElip         Timing.
  2261.  
  2262.         ELIPMB         ElipMB
  2263.         ELIPMBR        ElipMBR
  2264.         ELIPDA2        ElipDA2
  2265.         ELIPDAF        ElipDAF
  2266.         ELIPDAI        ElipDAI
  2267.         ELIPDAM        ElipDAM
  2268.         ELIPRA         ElipRA
  2269.         ELIPRA2        ElipRA2
  2270.         ELIPRAF        ElipRAF
  2271.         ELIPRAF2       ElipRAF2
  2272.         ELIPRAI2       ElipRAI2
  2273.         ELIPRAM        ElipRAM
  2274.  
  2275.         Parabola Routines
  2276.  
  2277.         DEMOPARA       DemoPara         Demonstrate parabola routines.
  2278.         BNCHPARA       BnchPara         Timing.
  2279.  
  2280.         PARAMB         ParaMB
  2281.         PARAMBR        ParaMBR
  2282.         PARARA         ParaRA
  2283.         PARARAF        ParaRAF
  2284.  
  2285.         Hyperbola Routines
  2286.  
  2287.         DEMOHYPR       DemoHypr         Demonstrate hyperbola routines.
  2288.         BNCHHYPR       BnchHypr         Timing.
  2289.  
  2290.         HYPRMB         HyprMB
  2291.         HYPRMBR        HyprMBR
  2292.         HYPRDA         HyprDA
  2293.         HYPRDAF        HyprDAF
  2294.         HYPRDAM        HyprDAM
  2295.         HYPRDAMG       HyprDAMG
  2296.          (SAR)         n/a
  2297.         HYPRRA         HyprRA
  2298.         HYPRRAF        HyprRAF
  2299.         HYPRRAM        HyprRAM
  2300.  
  2301.  
  2302.         NOTES
  2303.  
  2304.  
  2305.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.         =====
  2315.  
  2316.         1. For most centers only one hyperbolic branch or asymptote,
  2317.            at most, is required.  Likewise for parabolae.
  2318.  
  2319.         2. TURBO Pascal and Topspeed Modula-2 lack a shift arithmetic 
  2320.            right capability.  Many of the routines use div to get arith-
  2321.            metic right shifts.  This is typically one third again as 
  2322.            slow.  For example, in the HYPERBOLA table the entry (SAR) is 
  2323.            a special test of routine HYPRDAMG where the rotation angle is 
  2324.            restriced to first quadrant and shr is substituted for div to 
  2325.            show sar timing effect.  Note that div and sar would not be 
  2326.            equivalent and each application would have to be tested.  For 
  2327.            example, -7 div 2 = -3, while -7 sar 1 = -4, etc. 
  2328.  
  2329.            Likewise, neither TURBO nor TopSpeed has a facility to direct-
  2330.            ly manipulate a floating point exponent.  An IncExp and DecExp 
  2331.            function would enable rapid power of two operations.
  2332.  
  2333.         3. It is surprising that TURBO's BGI and TopSpeed's GRAPH circle 
  2334.            and ellipse routines are so slow - especially when it is noted 
  2335.            that all the routines presented here are higher order language.  
  2336.  
  2337.         4. Note that the timing comparisons are for a random selection of 
  2338.            parameters.  If the tests are restriced to the parameter 
  2339.            ranges for which the respective routines are ideal, then the 
  2340.            minimum angle routines are 5-10 times faster.  For example, if 
  2341.            radii for CIRCDAM2 are set at 510 then TURBO Circle requires 
  2342.            0.903 sec while the fixed point `minimum' difference angle 
  2343.            routine requires about the same 0.192 sec per figure.
  2344.  
  2345.         5. A high performance implementation of minimum angle ideas would 
  2346.            justify a polyalgorithm where the parameter set is matched to 
  2347.            specified radius for several radius ranges.  This algorithm 
  2348.            would also economically compensate the radius dependent offset 
  2349.            noted in defect testing for smaller radii.
  2350.  
  2351.            A high performance implementation of rotation angle or 
  2352.            difference angle ideas would allow overlap of numeric 
  2353.            coprocessor operation with graphics operations.  That is, the 
  2354.            coordinates for the next stroke could be generated while the 
  2355.            pixels on the present stroke are toggled.
  2356.  
  2357.         6. Another kind of fixed point routine is possible where the 
  2358.            scaling shift necessary to normalize radius is computed and 
  2359.            used to scale for coordinate computation and descale for 
  2360.            display variable computation.  For the anticipated range of 
  2361.            display resolutions and radii the B6 scaling for circles and 
  2362.            ellipses and B0 scaling for hyperbolae is probably adequate.
  2363.  
  2364.         7. Two natural logarithms is a lot of arithmetic to get a useful 
  2365.            stroke count for hyperbolae.
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.         8. The defect counts indicate disagreement between TURBO's Circle 
  2381.            and stroked circles of about one pixel in seven or eight when 
  2382.            using TURBO's GetAspectRatio parameters.
  2383.  
  2384.         9. Overhead in calls to Line, for example, moderates use of 
  2385.            higher than quadrant symmetry.  That is, routine performance 
  2386.            is not greatly improved by using octant symmetry over quadrant 
  2387.            symmetry because stroke computation is reduced but argument 
  2388.            fetch, etc. is not.
  2389.  
  2390.         10. Neither TURBO nor TopSpeed appear to be using the numeric 
  2391.            coprocessor for integer and long integer operations.  Note the 
  2392.            anomalous TopSpeed results where routines run faster without 
  2393.            numeric coprocessor, i.e. Circle and Ellipse.  TopSpeed does 
  2394.            not appear to have an option to disable coprocessor usage and 
  2395.            has a double or nothing floating operand restriction.
  2396.  
  2397.         11. If increment and minimum angle tableaus for scalings above 
  2398.            about B20 are required then floating point arithmetic in INCxx 
  2399.            and MINxx routines should be done double rather than single.
  2400.  
  2401.         12. These same incremental and minimum angle ideas are applicable 
  2402.            to fast Fourier and fast Hartley transforms as well as to 
  2403.            function generation, particularly, variable precision function 
  2404.            generation.
  2405.  
  2406.         13. Using extremum point geometry for parabolas means that 
  2407.            parameters greater than about 400 don't draw anything because 
  2408.            the extremum point is outside the coordinate limits as given.  
  2409.            
  2410.            The routines can be reformulated to use vertex point geometry, 
  2411.            cf. HyprMBR, which requires an additional loop per asymptote.  
  2412.            
  2413.            Coordinate limits may be imposed with a Cartesian norm, e.g., 
  2414.            abs(ix) + abs(ix) < irx, which relieves the problem slightly 
  2415.            with some penalty in running time.
  2416.  
  2417.         14. TopSpeed's GRAPH restriction of Circle, etc., centers to 
  2418.            cardinal values is unnecessarily restrictive.  Further, the 
  2419.            restriction of Line coordinates to cardinal values is 
  2420.            unaccept-able, particularly because the compiler accepts 
  2421.            integer arguments.  What happens is that GRAPH's Line routine 
  2422.            treats the negative values as large cardinal values and tests 
  2423.            the whole range for display.  Such arguments make the display 
  2424.            appear to be inoperable for 10's of seconds.  Use the Line 
  2425.            routine from GraphFun.MOD.  This routine could be further 
  2426.            improved for closed figure application by noting that both end 
  2427.            points do not have to be displayed.
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.         COMMENTS
  2447.         ========
  2448.  
  2449.         1. It would be useful to have a simple graphics standard for 
  2450.            display scaling and aspect.  This might not require an inter-
  2451.            national conference.  Just a set of conventions so that a 
  2452.            procedure call, e.g. Circle(200,200,100), produced a round 
  2453.            circle with the same display relative size and positioning 
  2454.            independent of display adapter. 
  2455.  
  2456.         2. Neither TURBO's nor TopSpeed's graphics libraries can be 
  2457.            recommended for speed.  It would help to combine line and 
  2458.            pixel routines and drop color as an argument for each pixel.
  2459.  
  2460.         3. As a rule, TURBO 4.0 does better than TopSpeed 1.14 with 
  2461.            floating point while TopSpeed does better than TURBO with 
  2462.            fixed point.
  2463.  
  2464.  
  2465.         OBSERVATIONS
  2466.         ============
  2467.  
  2468.         1. To this author, the displays produced when parabolae with 
  2469.            random parameters are displayed vaguely but often suggest a 
  2470.            network or lattice with nodes and correlated asymptotes.  Ran-
  2471.            dom ellipses and hyperbolae do dot produce the same effect.  
  2472.  
  2473.            I wonder if Lowell was observing something similar.
  2474.  
  2475.  
  2476.         NOTICES
  2477.         =======
  2478.  
  2479.         CP/M (c) Digital Research Corporation
  2480.         MS-DOS (c) Microsoft Corporation
  2481.  
  2482.         TURBO Pascal (c) Borland International
  2483.         TopSpeed Modula-2 (c) Jensen Partners, International
  2484.  
  2485.         Hercules (tm) Hercules, Inc.
  2486.  
  2487.         iAPX8086/8087 (tm) Intel Corporation
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.         Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.