aUCBLogo Demos and Tests / testdrawtrajectories2
to testdrawtrajectories2
drawit
stop
;The rest of this procedure is for use with Autoload Mode.
;Comment the upper drawit and stop,
;click on Run / Autoload File to Workspace,
;then press F9 (Run).
;(Don't forget to comment rotatescene at the bottom,
;else you'll get a nasty loop.)
;Then you can change the program while it is running.
;(which can be very useful for experimenting!)
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 initGraph
hideTurtle
perspective
clearScreen
WindowMode
setEye
; {100 200 500}
{-500 0 0}
{0 0 0}{0 1 0}
setPenSize 6
enableCylinderLines
disableRoundLineEnds
setPenColor HSBA 0 0 0 0.4
axes
end
be axes
home
pd setposxyz [1 0 0]*200
pu setposxyz [1 0 0]*220 seth 90 label "x
home pd seth 90 sphere 5
pd setposxyz [0 1 0]*200
pu setposxyz [0 1 0]*220 seth 90 label "v home
pd setposxyz [0 0 1]*200
pu setposxyz [0 0 1]*220 seth 90 label "a home
end
be plot x y z c
PenUp
setPenColor HSB c*60 1 1
setXYZ x.1*100 y.1*100 z.1*100
PenDown
setXYZ x*100 y*100 z*100
PenUp
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 x t)
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
null=rseqFA 0 0 N
plot tt x null 0
; plot x tx 0 1
plot x v a 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.7
t0=0
t1=1
N=100
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*1.4
xva2=compute x1 v1 a1 r1 t01 t11 N
x2=xva2.1.N
v2=xva2.2.N
a2=xva2.3.N
r2=-0.7
t02=t11+t1
t12=t1*1
xva3=compute x2 v2 a2 r2 t02 t12 N
end
be connect xstart xend
xx3=((xend-xstart)/0.952)^(1/3)
x0=xstart
v0=0.0
a0=0.0
r0=0.7
t0=0
t1=1*xx3
N=1000
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*1.4
xva2=compute x1 v1 a1 r1 t01 t11 N
x2=xva2.1.N
v2=xva2.2.N
a2=xva2.3.N
r2=0.7
t02=t11+t1
t12=t1
xva3=compute x2 v2 a2 r2 t02 t12 N
end
initGraph
; simplest waitforkey
; complexer waitforkey
; connectedLoop
; connection
connect 0 0.9
rotatescene
end