I want to generate a random number and use it later. It also works, the simulation loads like for 0.5 sec and then I see it. But then the simulation breaks down and the simulation window quits. I also can't use e.g. import random
it happens the same thing. Could it be that the random package doesn't work with Vpython?
from vpython import*
import random from randint
#Sonne
sun = sphere(pos = vec(0,0,0), radius = 9, make_trail = True )
sun.mass = 2e30
sun.velocity = vec(0,0,0)
#Merkur
mercury_pos_x = randint(1, 100)
mercury = sphere(pos = vec(mercury_pos_x,0,0), radius = 5, color=color.red, make_trail = True )
mercury.mass = 3.25e23
mercury.velocity = vec(0,0,-47000)
#Venus
venus_pos_x = randint(1, 100)
venus = sphere(pos = vec(venus_pos_x,0,0), radius = 6, color=color.cyan, make_trail = True )
venus.mass = 4.9e24
venus.velocity = vec(0,0,-35000)
Aucun commentaire:
Enregistrer un commentaire