Circle plotted with integer (sinus/cosinus table) 0-360 degrees.
How is that with ccz80 ++ ?.
thank you.
i suggest you to use the Andrès method instead of cos/sin method
it uses only simple operations and there is no hole between two circles of size/size+1
description in French but algo/code is algo/code
https://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_de_cercle_d'Andres
I think @ervin (http://www.cpcwiki.eu/forum/index.php?action=profile;u=82) posted some ccz80 code for a Bresnan circle routine which is totally integer based
I found the post (wasn't easy locating from a iPhone):
http://www.cpcwiki.eu/forum/programming/cpc-basic-3/msg100801/#msg100801
thank you.
The solution found.
greeting
include Indirections6128.ccz80++
include Text.ccz80++
include Keyboard.ccz80++
include Graphics.ccz80++
class Test
{
static int tg_curx, tg_cury, sign, theta,grad;
static int wert,deltax,deltay,length,x,y,xp,yp;
static short winkel[] = {
0 , 2 , 4 , 7 , 9,
11 , 13 , 16 , 18 , 20,
22 , 24 , 27 , 29 , 31,
33 , 35 , 37 , 40 , 42,
44 , 46 , 48 , 50 , 52,
54 , 56 , 58 , 60 , 62,
64 , 66 , 68 , 70 , 72,
73 , 75 , 77 , 79 , 81,
82 , 84 , 86 , 87 , 89,
91 , 92 , 94 , 95 , 97,
98 , 99 , 101 , 102 , 104,
105 , 106 , 107 , 109 , 110,
111 , 112 , 113 , 114 , 115,
116 , 117 , 118 , 119 , 119,
120 , 121 , 122 , 122 , 123,
124 , 124 , 125 , 125 , 126,
126 , 126 , 127 , 127 , 127,
128 , 128 , 128 , 128 , 128,
128 };
static void main()
{
short a;
Graphics.GraphicsMode(1);
Graphics.Clg();
while(1)
{
a=Keyboard.Inkey();
if(a=='d')
{
Text.Locate(15,12);
Text.PrintString("ein Kreis...");
for (grad = 0; grad <= 360; ++grad)
{
x=320;
y=200;
length=190;
plot_win();
}
}
}
}
static void tg_isin()
{
sign=1;
theta=grad;
if(theta>180)
{
theta=360-theta;
sign=-1;
}
if(theta>90)
{
theta=180-theta;
}
wert=sign*winkel[theta];
}
static void tg_icos()
{
sign=1;
theta=grad;
if(theta>180)
{
theta=360-theta;
}
if(theta>90)
{
theta=180-theta;
sign=-1;
}
wert=sign*winkel[90-theta];
}
static void plot_win()
{
tg_curx=x << 7;
tg_cury=y << 7;
tg_isin();
deltay=length*wert;
tg_icos();
deltax=length*wert;
tg_curx=tg_curx+deltax;
tg_cury=tg_cury-deltay;
xp=tg_curx >> 7;
yp=tg_cury >> 7;
Graphics.Plot(xp,yp);
}
}