Nem ugyanaz...
hwsw famulus
hwsw at famulus.hu
Thu Apr 15 21:49:38 CEST 2004
> >Ezert kell csak nyolcadot rajzoltatni vele, a maradekot lehet tukrozni
> (koordinatacsere, osszeadas-kivonas).
>
> Persze, ezzel meginkabb lehet gyorsitani a dolgon. Abban Ferinek lehet
> igaza, hogy nyilvan megis a szinuszost hasznalhattak a commodere
> basic-ekben, mert mint irtam is, a lepeskozt finomra kell venni, a nem
> egyenletes pontossab miatt pithagorasz-nal.
> A szinuszos meg megy egy letarolt tablabol eszmeletlen gyorsan.
> Az jo kerdes, hogy a 8-szoros ternyolcadolas+osszeadas/kivonasok
> sorozata, vagy pedig a letabellazott szinuszfuggveny indexelt cimzessel
> torteno elerese a gyorsabb. Talan en a helyedben nem fokokban, hanem
> radianban dolgoznek, akkor siman sin(alfa)*r, meg cos(alfa)*r
> Szamitas eleg lenne. Vagyis ket szorzas, illetve visszakereses
> pixelenkent. Ez azert gyorsithat szinten valamelyest. A szamitasnal
> fixpontos alakban dolgoznek, (2..3 tizedes) az jo gyors.
>
> Erre meg talan valamit ragyorsithatna a nyolcados eljaras is...
>
> >Az betoltott program nelkul semmit sem rajzolt ki. Simon's BASICre vagy
> hasonlora gondolsz?
>
> Je, meglehet... :)))) Regen volt.
>
> Udv.:
> Norbi.
Valaki mar hivatkozott a Bresenham algoritmusra...probaltatok mar?
Az csak osszeadas, kivonas, balrashift muveletbol all !!!
KJ
---------------------
Bresenham's circle algorithm calculates the locations of the pixels in the first 45 degrees. It assumes that the circle is centered on the origin. So for every pixel (x,y) it calculates we draw a pixel in each of the 8 octants of the circle :
PutPixel(CenterX + X, Center Y + Y)
PutPixel(CenterX + X, Center Y - Y)
PutPixel(CenterX - X, Center Y + Y)
PutPixel(CenterX - X, Center Y - Y)
PutPixel(CenterX + Y, Center Y + X)
PutPixel(CenterX + Y, Center Y - X)
PutPixel(CenterX - Y, Center Y + X)
PutPixel(CenterX - Y, Center Y - X)
So let's get into the actual algorithm. Given a radius for the circle we perform this initialisation:
d := 3 - (2 * RADIUS)
x := 0
y := RADIUS
Now for each pixel we do the following operations:
'Draw the 8 circle pixels
if d < 0 then
d := d + (4 * x) + 6
else
begin
d := d + 4 * (x - y) + 10
y := y - 1;
end;
And we keep doing this until x = y. Note that the values added to the decision variable in this algorithm (x and y) are constantly changing, so we cannot precalculate them. The muliplications however are by 4, and we can accomplish this by shifting left twice.
More information about the Elektro
mailing list