Wednesday, December 2, 2009

routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.


(x ^ 2 + y ^2 = r ^ 2)...................................1 

The basic idea is to draw one quadrant and replicate it to other four quadrants.
Assuming the center is given as (a,b) and radius as r units, then start X from (a+r) down to (a) and start Y from (b) up to (b+r). In the iteration, keep comparing is the equation (1) is satisfied or not within an error of one unit for a and b. If not then re-adjust X and Y.

No comments:

Post a Comment