🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.16k
Article #253

DSI-32 : A problem in C - Help!

#253
From: 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);
}
Technical Details
Message-ID: <352@utastro.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!ut-sally!utastro!jk

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!gatech!ut-sally!utastro!jk
From: jk@utastro.UUCP (John Krist)
Newsgroups: net.micro.16k
Subject: DSI-32 : A problem in C - Help!
Message-ID: <352@utastro.UUCP>
Date: Mon, 10-Feb-86 23:06:35 EST
Article-I.D.: utastro.352
Posted: Mon Feb 10 23:06:35 1986
Date-Received: Wed, 12-Feb-86 20:34:41 EST
Organization: U. Texas, Astronomy, Austin, TX
Lines: 50
Keywords: Just after I posted the last article....