-----Original Message-----
From: Max Bian [mailto:[EMAIL PROTECTED]]
Sent: Monday, 14 January 2002 12:06 PM
To: Palm Developer Forum
Subject: RE: drawing....


> Circle is defined as x^2 + y^2 = R^2 in the usual x-y coordinate. 
> Mathematically, if R=0, it is a point; if it is infinite, that's nothing.

Ok, that's an agrument indeed. But remember, we were discussing a mid-point
algorithm.

Sorry for a long off-topic remark. We were discussing a Mid-Point algorithm.
And it is about the following:

Take the first quadrant of the circle while, all other are symmetric to it.
Choose counter-clockwise drawing. You have x always decremented by 1
(dx=-1), while y can be incremented by 1, or can stay, therefore dy is 0 or
1, and all we need is to find the actual dy value.

The idea is the following: you have an equation: f(x,y) = 0, where f(x,y) is
a polynomial.

In case of a line:
        f(x,y) = a*x + b*y + c

In case of a canonic circle (centre in the origin):
        f(x, y) = x*x + y*y - r*r

But a circle is not necessarily canonic, so that it is generally 
        f(x, y) = a*x*x + b*y*y + c*x + d*y + e

Where a and b are somehow related to the curvature. When curvature is zero,
we have both a=0 and b=0, therefore we get a line!

Should I continue with Mid-Point ? 

Well, dx is always (-1), whether y goes up or stays depends on the location
of the middle point
        g(x,y) = f(x+1, y+0.5), 

i.e. (in C syntax) 
        dy = g(x, y) >= 0 ? 1 : 0. 

The Bresenham's trick is that we don't need to re-evaluate g(x,y). Instead
we compute the increment of g(x,y) which is one power order less! This
increment is related to first derivative, which in term is related to
curviture! For a line DeltaG = a  or (a+b) (depending on whether y
increments),
for a circle it is variable: (like 2*x+3 and 2*x+5 for the canonic circle)
but still line (from this prospective) is a reduced circle.

Michael

        


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to