fb:porticula NoPaste
Zwei Kreise mit Distanz berechnen
Uploader: | Löwenherz |
Datum/Zeit: | 20.08.2009 21:24:28 |
'====================================================================
' Zwei Kreise
'====================================================================
Randomize TIMER * 1e6
DIM AS INTEGER xs, ys
SCREENINFO xs, ys
SCREENRES xs, ys, 4
DIM AS STRING s
DIM AS DOUBLE h = ys / 2
DIM AS DOUBLE q = ys / 4
DIM AS DOUBLE xc1, yc1, rc1 ' Kreis 1
DIM AS DOUBLE xc2, yc2, rc2 ' Kreis 2
DIM AS DOUBLE dx, dy, beruehren, distanz ' separation
'--------------------------------------------------------------------
DO
CLS
'--------------------------------------------------------------------
' erster kreis
xc1 = RND * h + q
yc1 = RND * h + q
rc1 = 10 + ys * RND / 5
CIRCLE(xc1, yc1), rc1, 14
PSET (xc1, yc1), 14
'--------------------------------------------------------------------
' zweiter kreis
xc2 = RND * h + q
yc2 = RND * h + q
rc2 = 10 + ys * RND / 5
CIRCLE(xc2, yc2), rc2, 13
PSET (xc2, yc2), 13
LINE (xc1, yc1)-(xc2, yc2), 7
'--------------------------------------------------------------------
beruehren = rc1 + rc2
dx = xc1 - xc2
dy = yc1 - yc2
distanz = SQR(dx*dx + dy*dy)
PRINT
PRINT " Esc druecken, anderer Key fuer Aktion wiederholen."
PRINT
IF distanz > beruehren THEN
PRINT " kreise beruehren sich nicht"
ELSE
PRINT "kreise ueberlappen sich"
END IF
PRINT
PRINT "distanz ist: "; distanz
PRINT
'--------------------------------------------------------------------
DO ' warten bis key gedrückt
s = INKEY
LOOP UNTIL s <> ""
IF ASC(s) = 27 THEN EXIT DO ' esc drücken für EXIT
LOOP
'====================================================================
SLEEP
'====================================================================