fb:porticula NoPaste
SIN/COS Beispiel für QB
Uploader: | Sebastian |
Datum/Zeit: | 03.03.2008 15:41:25 |
'Kleines Beispiel zur Verwendung von Sin(x) und Cos(x)
'und zur Bogenmaßumrechnung
'von Sebastian Steiner, 03/2008
'für QB!
'Als Beilage zum Forenthema: http://forum.qbasic.at/viewtopic.php?t=5394
DECLARE FUNCTION DEG2RAD# (Winkel AS INTEGER)
CONST yMax = 225
DIM SHARED Pi AS DOUBLE
Pi = 4# * ATN(1#)
SCREEN 12
LOCATE 2, 26: PRINT "Sin/Cos Demo"
LOCATE 29, 42: PRINT "Beliebige Taste drcken."
LINE (20, 15)-(20, 465), 15
LINE (10, 240)-(630, 240), 15
LINE (15, 20)-(20, 15), 15
LINE (25, 20)-(20, 15), 15
LINE (625, 235)-(630, 240), 15
LINE (625, 245)-(630, 240), 15
CIRCLE (20, 240), 5, 15
DIM x AS INTEGER
DIM y AS DOUBLE
DIM ly AS DOUBLE
ly = yMax
FOR x = 1 TO 610
y = yMax - SIN(DEG2RAD(x)) * yMax
LINE (19 + x, ly + 15)-(20 + x, y + 15), 14
ly = y
NEXT x
ly = 0
FOR x = 1 TO 610
y = yMax - COS(DEG2RAD(x)) * yMax
LINE (19 + x, ly + 15)-(20 + x, y + 15), 12
ly = y
NEXT x
SLEEP
END
FUNCTION DEG2RAD# (Winkel AS INTEGER)
DEG2RAD# = (2 * Pi * Winkel) / 360
END FUNCTION