Re: circles



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

.



Relevant Pages

  • Re: coverage are simulation ..help me...pixel region generation
    ... production of deployment region C consisting of pixels. ... which is made up of 19634803 pixels, has a radius of 5000 pixels. ... Then create, within that square, a circle of your ... N and plot your mean area fraction as a function of N. As a sanity ...
    (comp.soft-sys.matlab)
  • Re: Determine angle of a point on a circle?
    ... on a circle of radius r centered ... simpler if we work in polar coordinates instead. ... The length of L is r and the angle between L and ...
    (sci.math)
  • Re: about phase and frequency
    ... >> Good grief! ... >> Fixed font needed, this is a circle. ... >> A is the radius, ... >> w is the angle. ...
    (sci.physics)
  • Re: trig problem
    ... >> Let Cxr be the cirle with center X and radius R. ... >> For an arbitrary point Y, define Aas the angle of the vector ... > therefore lies on an arc of a circle having OX as a chord. ...
    (sci.math)
  • Re: radar rendering
    ... scans arrive one at a time in real time as the radar spins around. ... rendered radar 'circle' could have any radius, ... and assume that the radius will be 512 pixels. ... but this being a circle of radius 512, this boundary curve is over 3000 pixels long. ...
    (comp.graphics.algorithms)