aUCBLogo Demos and Tests / testdrawtrajectories
to testdrawtrajectories
drawit
stop
;rest of this procedure is for use with autoload mode
setUpdateGraph "false
a=0
forever
[ clearScreen
;pr repcount
catch "error [ignore runResult [drawit]]
err=Error
if :err != []
[ clearText
print :err.2
waitMS 200
]
updategraph
updateVars
dispatchMessages
waitMS 100
if Key? [stop]
]
end
be drawit
be plot x y c
PenUp
setXY x.1 y.1
PenDown
setPenColor c
setXY x y
end
be initGraph
hideTurtle
clearScreen
WindowMode
setScreenRange -5 -3*5/4 5 3*5/4
setPenSize 0
end
be waitForKey
print [Please press any key to continue...]
ignore readchar
end
be compute x0 v0 a0 r t0 t1 N
t=rSeqFA 0 t1 N
x=t*v0+t*t*a0/2+t*t*t*r/6+x0
t_of_x=Table N
repeat N
[ i=repcount
xi=x.i
t_of_x.xi=t.i
]
xmax=(max x)
tx=FloatArray t_of_x.x
v=tx*a0+tx*tx*r/2+v0
a=tx*r+a0
tt=rSeqFA t0 t0+t1 N
plot tt x 0
; plot x tx 1
plot x v 2
updateGraph
(print x.N v.N a.N)
output (list x v a)
end
be simplest
x0=0.0
v0=0.0
a0=0.0
r=-0.5
t0=0
t1=3
N=1000
xva=compute x0 v0 a0 r t0 t1 N
end
be complexer
x0=0.0
v0=0.5
a0=0.0
r=-0.5
t0=0
t1=3
N=1000
xva=compute x0 v0 a0 r t0 t1 N
end
be connectedLoop
x0=0.0
v0=0.0
a0=0.0
r=-1
t0=0
t1=1
N=10
xva=compute x0 v0 a0 r t0 t1 N
x1=xva.1.N
v1=xva.2.N
a1=xva.3.N
r1=3
t01=t1
t11=t1
xva2=compute x1 v1 a1 r1 t01 t11 N
x2=xva2.1.N
v2=xva2.2.N
a2=xva2.3.N
r2=-3
t02=t01+t1
t12=t1
xva2=compute x2 v2 a2 r2 t02 t12 N
x2=xva2.1.N
v2=xva2.2.N
a2=xva2.3.N
r2=1
t02=t02+t1
t12=t1
xva2=compute x2 v2 a2 r2 t02 t12 N
end
be connection
x0=0.0
v0=0.0
a0=0.0
r0=-0.8
t0=0
t1=1
N=10
xva=compute x0 v0 a0 r0 t0 t1 N
x1=xva.1.N
v1=xva.2.N
a1=xva.3.N
r1=1
t01=t1
t11=t1*2
xva2=compute x1 v1 a1 r1 t01 t11 N
end
initGraph
; simplest waitforkey
; complexer waitforkey
; connectedLoop
connection
end