CoCalc Public Filesvpython.ipynbOpen with one click!
Author: Harald Schilly
Views : 75
Description: Jupyter notebook vpython.ipynb
Compute Environment: Ubuntu 18.04 (Deprecated)

umask 022; /projects/sage/sage-7.3/sage -pip install --no-deps --ignore-installed vpython vpnotebook ivisual ujson crayola

In [3]:
from __future__ import division import vpython
In [4]:
vpython.sphere()
In [6]:
from ivisual import * redbox=box(pos=vector(4,2,3), size=(8,4,6),color=color.red) ball=sphere(pos=vector(4,7,3),radius=2,color=color.green)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
(not running untrusted Javascript)
In [5]:
from __future__ import division, print_function from ivisual import *
ERROR! Session/line number was not unique in database. History logging moved to new session 93
In [7]:
print( "hello")
hello
In [8]:
import ivisual #print ivisual
In [ ]:
from ivisual import * scene = canvas('Ball in Box') print(""" Right button drag to rotate "camera" to view scene. On a one-button mouse, right is Command + mouse. Middle button to drag up or down to zoom in or out. On a two-button mouse, middle is left + right. On a one-button mouse, middle is Option + mouse. """) side = 4.0 thk = 0.3 s2 = 2*side - thk s3 = 2*side + thk wallR = box (pos=( side, 0, 0), size=(thk, s2, s3), color = color.red) wallL = box (pos=(-side, 0, 0), size=(thk, s2, s3), color = color.red) wallB = box (pos=(0, -side, 0), size=(s3, thk, s3), color = color.blue) wallT = box (pos=(0, side, 0), size=(s3, thk, s3), color = color.blue) wallBK = box(pos=(0, 0, -side), size=(s2, s2, thk), color = (0.7,0.7,0.7)) #ball = sphere (color = color.green, radius = 0.4) ball = sphere (color = color.green, radius = 0.4, make_trail=True, interval=5, retain=30) #ball = cone (color = color.green, radius = 0.4, make_trail=True, interval=5, retain=30) ball.mass = 1.0 ball.p = vector (-0.15, -0.23, +0.27) side = side - thk*0.5 - ball.radius display(scene) dt = 0.5 t=0.0 while t < 2000: rate(100) t = t + dt ball.pos = ball.pos + (ball.p/ball.mass)*dt if not (side > ball.x > -side): ball.p.x = -ball.p.x if not (side > ball.y > -side): ball.p.y = -ball.p.y if not (side > ball.z > -side): ball.p.z = -ball.p.z
(not running untrusted Javascript)
Right button drag to rotate "camera" to view scene. On a one-button mouse, right is Command + mouse. Middle button to drag up or down to zoom in or out. On a two-button mouse, middle is left + right. On a one-button mouse, middle is Option + mouse.
In [ ]:
In [ ]: