Re: circles
- From: aiiadict@xxxxxxxxx
- Date: 25 Feb 2006 10:44:17 -0800
Your method is easier if speed is not critical.
Speed is the aim of the routine.
I am currently using trig to calculate the coordinates of a pixel,
given the angle and radius. To fill the circle, I start with a radius
of 1, and cycle through all values up to the radius. VERY slow.
Using Bresenhams algorithm, you end up calculating
only 45 degrees of the circle. The pixels get drawn
at 8 different points. This is the only method that I've
understood so far, so it is what I'm working with.
I'm working with an idea I had the other day...
bresenhams algorithm starts with X=0, Y = radius
and it loops until X=Y (45degrees)
I can store The x,y coordinates of each point.
X changes (increments) each time the algorithm loops.
I can take the END X, subtract the START X (which is zero),
and find out how many pixels are lit in 45 degrees
of the circle.
45 / ( EndX - StartX) = pixels per degree (also X increments per
degree)
the rest of this post describes a test with radius = 50
then if I want a 45 degree circle segment with a
center angle of 35 degrees (a=35):
SA = A -22.5 (start angle for circle segment)
sa = 35 - 22.5
sa = 13.5
EA = A + 22.5 (END angle for circle segment)
Ea = 35 + 22.5
Ea = 57.5
startangle = 13.5
now to find the X/Y for this angle of the circle
I JUST RAN A TEST in the emulator,
radius = 50
takes 36 pixels per 45 degrees
45/36
it takes 1.25 pixels per degree...
I put each pixel's coordinates into an array,
X(np)
Y(np)
I want to start at angle 13.5, and draw the arc
until angle 57.5
(pixels per degree) * (angle in degrees) = X coordinate value at this
point
1.25 * 13.5 = 16.875
In my array of coordinates, there is only 1 X
that is close to 16.8.. The one at 17.
The Y is = 47 when x = 17
I know my start X,Y.
maybe I can use bresenhams algorithm to draw the rest
of the octant, and then to the next octant to
draw the other "half" of the arc.
thoughts, criticism, better explanation of other
methods?
other routines to run and compare execution
time?
Rich
.
- Follow-Ups:
- Re: circles
- From: Michael J. Mahon
- Re: circles
- From: sicklittlemonkey
- Re: circles
- From: aiiadict
- Re: circles
- References:
- circles
- From: aiiadict
- Re: circles
- From: David Empson
- Re: circles
- From: aiiadict
- Re: circles
- From: sicklittlemonkey
- Re: circles
- From: aiiadict
- Re: circles
- From: sicklittlemonkey
- circles
- Prev by Date: Re: 'vi' for IIgs
- Next by Date: Re: circles
- Previous by thread: Re: circles
- Next by thread: Re: circles
- Index(es):
Relevant Pages
|