🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by John Krist Tue, 11 Feb 1986 04:06
DSI-32 : A problem in C - Help!
#253
Author: John Krist
Date: Tue, 11 Feb 1986 04:06
50 lines
1908 bytes
    Well, just after I finished with the update article, I began modifying
  the graphics routines for the DSI-32 virtual graphics library.  I decided
  to substitute the included line drawing routine with the DDA routine
  show here.  After I coded it, I tested it for speed and such just by timing
  (no pixel mapping routines included, just the calculations).  To my suprise,
  I got the wrong answer.  I converted it to fortran and got the right answer,
  so I tested it on the VAX here, and also got the right answer with the same
  identical C code - 20001.5.
    My C gives me 19893.5 !
  If anyone out there can run this on there DSI and get the right results,
  please tell me (I've got the December 1985 dated compilers).

  Thanks,
   John Krist
   {allegra,ihnp4}!{noao,ut-sally}!utastro!jk  

  DDA line drawing code:

     
#include <math.h>
#include <stdio.h>
main()

{
      float x1,x2,y1,y2,rlength,xinc,yinc,x,y;
      int i;

      x1=0.;
      x2=20000.;
      y1=0.;
      y2=20000.;

      rlength = fabs ( x2-x1 );
      if (fabs( y2-y1 ) > rlength )
         rlength = fabs ( y2-y1 );

      xinc = ( x2-x1 ) / rlength;
      yinc = ( y2-y1 ) / rlength;
      x = x1 + .5;
      y = y1 + .5;

      while ( i <= rlength )
       {
        x = x + xinc;
        y = y + yinc;
        i++;
       }
       printf ("%.6f\n",x);
}
Re: DSI-32 : A problem in C - Help!
#255
Author: Joe Devincentis
Date: Tue, 18 Feb 1986 03:03
21 lines
1120 bytes
[eat at joes]


As my modem is also eating things, I will be brief. 

The i variable is never initialized, making this loop dependent on Zuut for
luck.

      while ( i <= rlength )
       {
        x = x + xinc;
        y = y + yinc;
        i++;
       }
       printf ("%.6f\n",x);

Lint caught this for me right away.

					devoz@encore
					Joe DeVincentis
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads