Windowtitle "Umkreis berechnen y zeigen"
' (CL) Copyleft 2012-08 P. Pájaro carpintero
' {z.B. a Vorbereitung para el Flip-Operation el Delauney-Triangulation }
Declarar x!,y!,x0!,y0!,x1!,y1!,x2!,y2!,xu!,yu!,error%,nenn!,r!
Declarar y01!,yy2!,yy0!,xx0!,yy1!,xx1!,xx2!,x10!,x02!,x21!
Declarar xu0!,yu0!,xxu0!,yyu0!
Font 2 : Selección aleatoria : var xm!=%maxx/2:var ym!=%maxy/2
Ventana 0,0 - %maxx,%maxy
Cls rgb(246,246,246)
AppendMenuBar 10,"Bitte con Ratón Dreieckspunkte clic..."
otra vez:
WaitMouse
x0!=%mousex
y0!=%mousey
usepen 0,2,0
point x0!,y0!
WaitMouse
x1!=%mousex
y1!=%mousey
usepen 0,2,0
point x1!,y1!
usepen 0,1,0
line x0!,y0! - x1!,y1!
WaitMouse
x2!=%mousex
y2!=%mousey
usepen 0,2,0
point x2!,y2!
usepen 0,1,0
line x0!,y0! - x2!,y2!
line x1!,y1! - x2!,y2!
y01!=y0!-y1!
yy2!=y2!*y2!
yy0!=y0!*y0!
xx0!=x0!*x0!
yy1!=y1!*y1!
xx1!=x1!*x1!
xx2!=x2!*x2!
x10!=x1!-x0!
x02!=x0!-x2!
x21!=x2!-x1!
nenn!=(2*(x10!*y2!+x02!*y1!+(x21!)*y0!))
ifnot (nenn!=0) or (y01!=0)
xu!=(y01!*yy2!-(yy0!-yy1!+xx0!-xx1!)*y2!-y0!*yy1!+\
(xx0!+yy0!-xx2!)*y1!+(xx2!-xx1!)*y0!) / nenn!
'xu!=((y0!-y1!)*y2!*y2!-(y0!*y0!+x0!*x0!-y1!*y1!-x1!*x1!)*y2!-y0!*y1!*y1!+\
'(x0!*x0!+y0!*y0!-x2!*x2!)*y1!+(x2!*x2!-x1!*x1!)*y0!) / \
'(2*((x1!-x0!)*y2!+(x0!-x2!)*y1!+(x2!-x1!)*y0!))
yu!=x10!/y01!*(xu!-(x0!+x1!)/2)+(y0!+y1!)/2
usepen 0,5,255
point xu!,yu!
xu0!=xu!-x0!
xxu0!=xu0!*xu0!
yu0!=yu!-y0!
yyu0!=yu0!*yu0!
r!=sqrt(xxu0!+yyu0!)
if r!<10000
usepen 0,1,255
circle xu!,yu!,r!
endif
endif
goto "nochmal"
proc point
parámetros x!,y!
rectangle x!+2,(y!+2) - (x!-2),y!-2
ENDPROC
proc circle : parámetros cx%,cy%,radius%
declarar x%,y%,error%
error% = -1*radius%
x% = radius%
y% = 0
mientras que (x% >= y%)
plot8points(cx%,cy%,x%,y%)
inc error%,y%
inc y%
inc error%,y%
if (error% >= 0)
dec error%,x%
dec x%
dec error%,x%
endif
endwhile
ENDPROC
proc plot8points : parámetros cx%,cy%,x%,y%
plot4points(cx%,cy%,x%,y%)
caso x%-y%: plot4points(cx%,cy%,y%,x%)
ENDPROC
proc plot4points : parámetros cx%,cy%,x%,y%
setPixl cx%+x%, cy%+y%
caso x%: setPixl cx% - x%, cy% + y%
caso y%: setPixl cx% + x%, cy% - y%
caso x%*y%: setPixl cx%-x%,cy%-y%
ENDPROC
proc setpixl
parámetros x%,y%
setpixel x%%,255
ENDPROC