September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
35
Task/Animate-a-pendulum/Smart-BASIC/animate-a-pendulum.smart
Normal file
35
Task/Animate-a-pendulum/Smart-BASIC/animate-a-pendulum.smart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'Pendulum
|
||||
'By Dutchman
|
||||
' --- constants
|
||||
g=9.81 ' accelleration of gravity
|
||||
l=1 ' length of pendulum
|
||||
GET SCREEN SIZE sw,sh
|
||||
pivotx=sw/2
|
||||
pivoty=150
|
||||
' --- initialise graphics
|
||||
GRAPHICS
|
||||
DRAW COLOR 1,0,0
|
||||
FILL COLOR 0,0,1
|
||||
DRAW SIZE 2
|
||||
' --- initialise pendulum
|
||||
theta=1 ' initial displacement in radians
|
||||
speed=0
|
||||
' --- loop
|
||||
DO
|
||||
bobx=pivotx+100*l*SIN(theta)
|
||||
boby=pivoty-100*l*COS(theta)
|
||||
GOSUB Plot
|
||||
PAUSE 0.01
|
||||
accel=g*SIN(theta)/l/100
|
||||
speed=speed+accel
|
||||
theta=theta+speed
|
||||
UNTIL 0
|
||||
END
|
||||
' --- subroutine
|
||||
Plot:
|
||||
REFRESH OFF
|
||||
GRAPHICS CLEAR 1,1,0.5
|
||||
DRAW LINE pivotx,pivoty TO bobx,boby
|
||||
FILL CIRCLE bobx,boby SIZE 10
|
||||
REFRESH ON
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue