I'm just trying to get used to Jupyter Notebook, using the silly example below.
2) I cannot find a 'find and replace' editing command. Do people normally edit the program in a different editor program?
3) I cannot see any wood structure in the floor? Furthermore, for instance marble does not seem to work. Why?
4) How can I make a sound from the program? (In the old version I used winsound with Beep and MessageBeep).
5) Why does the sphere look like a cigar? In the original program it was indeed a sphere.
6) How can I show the output in full screen (well, pressing F11 is kind of full screen, but the graphics is far from filling the full screen)?
from vpython import *
#from winsound import *
scene = display(title='Vpython-demo',x=0, y=0, width=1200, height=800,center=(0,0,0), background=color.black)
ceiling = box(length=2, height=0.05, width=2, color=color.yellow,pos=vec(0,1.025,0),material=materials.plastic,opacity=0.5)
floor = box(length=2, height=0.05, width=2, color=color.yellow,pos=vec(0,-1.025,0),material=materials.plastic)
table = box(length=1, height=0.05, width=1, color=color.red,pos=vec(0,-0.025,0),material=materials.wood)
leg1 = box(length=1.00, height=0.05, width=0.05, color=color.magenta,pos=vec(0.5,-0.50,-0.5),axis=vec(0,-1,0),material=materials.wood)
leg2 = box(length=1.00, height=0.05, width=0.05, color=color.magenta,pos=vec(0.5,-0.50,0.5),axis=vec(0,-1,0),material=materials.wood)
leg3 = box(length=1.00, height=0.05, width=0.05, color=color.magenta,pos=vec(-0.5,-0.50,-0.5),axis=vec(0,-1,0),material=materials.wood)
leg4 = box(length=1.00, height=0.05, width=0.05, color=color.magenta,pos=vec(-0.5,-0.50,0.5),axis=vec(0,-1,0),material=materials.wood)
bold=sphere(pos=vec(0.4,0.8,0),radius=0.1,color=color.blue,material=materials.plastic)
fjeder=helix(pos=vec(0,1,0), axis=vec(0,-0.2,0), radius=0.02,thickness=0.005,coils=10,color=color.magenta,material=materials.plastic)
lod=cylinder(pos=vec(0,0.8,0),axis=vec(0,-0.1,0),radius=0.05,color=color.green,material=materials.plastic)
g=9.82 #Acceleration of gravity
k=100 #Spring constant
m=0.5 #Mass of plumb
A=0.3 #Amplitude of oscillation
y0=0.5 #y-coordinate of equilibrium position
tau=2 #Dampning tid
eps=0.9 #Restitution coefficient
alpha=2/5
omega=sqrt(k/m)
h1=bold.pos.y-bold.radius
t1=sqrt(2*h1/g)
v1=-g*sqrt(2*h1/g)
omegay=3
t=0
told=t
dt=0.0004
while True:
rate(1000)
t=t+dt
lod.pos=vec(0,y0+A*cos(omega*t)*exp(-t/tau),0)
fjeder.axis=vec(0,lod.pos.y-1,0)
if t<t1:
ybold=bold.radius+v1*(t-t1)-g*(t-t1)**2/2
bold.pos=vec(0.4,ybold,0)
else:
v1=eps*v1
t1=t1-v1*2/g
#Beep(440,25)
#MessageBeep(-1)
ybold=bold.radius+v1*(t-t1)-g*(t-t1)**2/2
bold.axis=vec(cos(omegay*t),0,sin(omegay*t))
bold.pos=vec(0.4,ybold,0)
if -v1*2/g<dt:
break