[comp.lang.pascal] Circle algorithm

clane@libserv1.ic.sunysb.edu (Charles F Lane) (05/08/91)

	I recently bought Turbo Pascal v6.0 and I am just starting to learn
how to program with it.  I am interested in graphics and was disappointed to
find out that there is no support for 320x200 w/256colors in VGA (mode 19)
in the BGI driver.  I have been able to invoke mode 19 through BIOS Video 
Interrupt 10H and use Function Request 0CH to write dots to the screen.  I 
will have to make my own graphics unit that includes circles, rectangles, 
ellipses, etc.  What I need to know is what algorithm to use to draw circles.
I am using the following equations currently:

        X = r * COS(w)
	Y = r * SIN(w)

where r is the radius, w is the angle (0-360 plugged in to the equation), and
x and y are the coordinates of the points to be plotted to form the circle. 
There are two problems with this equation, though.  First, it is too
slooooooow!  Second, the larger the radius of the circle, the farther apart
the points are.  Thus, the circle is made of dots in the form of a circular
array is the result.  If anyone knows the circle algorithm that GRAPH.TPU
uses, I'll use that.  I want to be sure that if concentric circles are drawn
that there are no pixels missing in between, so keep that in mind when
providing a solution.  Thank you so much in advance!  

      P.S.  I hate to be a nag, but please respond directly via E-mail
            as I may not be able to read all postings before the older
            ones get periodically deleted.  Sometimes rn says, "6500
            unread messages" and only 150 of them are available! 

-- 
    
                         Charles F. Lane
                   clane@csserv1.ic.sunysb.edu

CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) (05/14/91)

In article <1991May8.153016.19558@sbcs.sunysb.edu>
  clane@libserv1.ic.sunysb.edu (Charles F Lane) wrote:

[...deleted...]

>ellipses, etc.  What I need to know is what algorithm to use to draw
>circles. I am using the following equations currently:
>
>        X = r * COS(w)
>        Y = r * SIN(w)
>
>where r is the radius, w is the angle (0-360 plugged in to the
>equation), and x and y are the coordinates of the points to be
>plotted to form the circle. There are two problems with this
>equation, though.  First, it is too slooooooow!  Second, the larger
>the radius of the circle, the farther apart

[...deleted...]

The subject of rapidly drawing good circles is common in programming
magazines. I'd particularly suggest you scan the last couple of
years of _Programmer's Journal_ and recent issues of Dr Dobbs'
Journal and Computer Language.

>      P.S.  I hate to be a nag, but please respond directly via
>            E-mail as I may not be able to read all postings before
>            the older ones get periodically deleted.  Sometimes rn
>            says, "6500 unread messages" and only 150 of them are
>            available!

I can't help but think that either you are subscribing to too many
lists, or you aren't reading your mail often enough--or both! ;)

+====================================================================+
| Karl Brendel                           Centers for Disease Control |
| Internet: CDCKAB@EMUVM1.BITNET         Epidemiology Program Office |
| Bitnet: CDCKAB@EMUVM1                  Atlanta GA  30093       USA |
|                        Home of Epi Info 5.0                        |
+====================================================================+