home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!uwm.edu!rutgers!cbmvax!cbmehq!cbmger!peterk
- From: peterk@cbmger.de.so.commodore.com (Dr Peter Kittel Germany)
- Newsgroups: alt.sys.amiga.demos
- Subject: Re: Drawing lines
- Message-ID: <9588@cbmger.de.so.commodore.com>
- Date: 15 Sep 92 07:52:02 GMT
- References: <umage.715709408@mcl>
- Reply-To: peterk@cbmger.de.so.commodore.com (Dr Peter Kittel Germany)
- Organization: Commodore Germany
- Lines: 34
-
- In article <umage.715709408@mcl> umage@mcl.ucsb.edu (androgyny) writes:
- >Yea me, the novitiate programmer again.
- >OK, i know the blitter will draw lines, but i wanted to try my hand at
- >writing a straight lin edrawer myself. And now i want to compare with
- >folks here. Keep in mind i've never had any teaching or theory in this,
- >and i've got a routine which requires 2 divides at the beginning of each
- >line, and from then on is simple adds and checks. (about 2 to 5 per pixel,
- >excluding actually drawing the pixel in ram) How does this measure up?
- >Should i think some more ? ( Of course i should! )
-
- Yes, go ahead, there are better solutions to find. I myself needed two
- or three years to reach the ultimate algorithm, only to find afterwards
- that it had already been invented in the 50's by some Mr. Bresenham at
- IBM. It's today known with his name, and it's also implemented in hardware
- in the blitter. Shall I really tell you? No. Just a hint: You can avoid
- any division by something that I called back then (before learning about
- Bresenham) "cross adding/subtracting". You investigate single-pixel steps
- on the longer axis of your line. Only once a while you also have to do a
- step in the other direction. Now the division is replaced by a continous
- subtraction: How often does the denominator fit into the nominator (sp?)?
- If you subtracted below zero, another step in the second direction is due.
- And to make up for the next interval, you add the dy=y2-y1 (positive!)
- to this *error* term, making it positive again, ready for the next
- subtractions of *dx* each. Then the only remainng question is how to
- initialize this error term: I just give it dy/2.
-
- Sigh, now I told you nearly all of Bresenham's algorithm. But there are
- differences: He always doubles some terms, where I do it much simpler,
- and I swear my lines look as decent as his ones!
-
- --
- Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions...
- Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk
- Back from vacation, anything happened?
-