[comp.sys.mac.programmer] Draw an arc

HEPING@kuhub.cc.ukans.edu (08/02/89)

What is the algorithm for QuickDraw to draw an arc?
Even though the given rect isn't a square, the angle from the 12 o'clock line
to the line which intersects the up right corner is always 45 degrees.
Is the algorithm secret? If not, could some one send me the algorithm or
a piece of code?

Thanks

Phil

awd@dbase.UUCP (Alastair Dallas) (08/03/89)

In article <7217@kuhub.cc.ukans.edu>, HEPING@kuhub.cc.ukans.edu writes:
> What is the algorithm for QuickDraw to draw an arc?

Arcs, ovals and circles (and lines) are converted to a raster display using
a DDA algorithm such as Bresenham's (sp?), generally.  This method starts at
one end and plots adjacent pixels based on the least error.  Books like
Foley and Van Dam, "Fundamentals of Computer Graphics," usually describe this
method in the first few chapters.

> Even though the given rect isn't a square, the angle from the 12 o'clock line
> to the line which intersects the up right corner is always 45 degrees.

This is to make it easy to specify portions of an oval in its own terms.
45 to 90 degrees gives you the same portion of any oval, even a circle.  If
you want to draw an arc starting from a 45-degree line, the simplest 
workaround is to make sure that the arc's rect is square.  Other than that,
you're going to have to do some math.  There are routines called SlopeFromAngle
and AngleFromSlope which might help, but I'm working from memory here--IM
is at home.

> Is the algorithm secret? If not, could some one send me the algorithm or
> a piece of code?

The basic DDA method is widely available, but I'm sure Quickdraw's specific
(and probably clever) implementation is proprietary.  Give the nuPrometheus
League a call and see what they can do for you.  :-)

> 
> Thanks
> 
> Phil

I posted this reply rather than emailing it because email bounces a lot for
me and posting always works.  If you'd like me to post more detail about
DDA algorithms in general, I wouldn't mind but some might.  I think such
a discussion would be reasonable here rather than comp.graphics, because
those guys are floating on clouds--I've stopped reading it altogether;
I was told there'd be no math.

/alastair/