CoCalc Public Filesjup.htmlOpen with one click!
Author: undefined undefined
Views : 69
Description: Jupyter html version of jup.ipynb
Compute Environment: Ubuntu 18.04 (Deprecated)
jup
In [1]:
# !pip install vpython --user --upgrade
In [2]:
#!pip install ivisual --user --upgrade
#!pip install ujson --user --upgrade
# from ivisual import *
In [1]:
from __future__ import division, print_function
from ivisual import *
scene = canvas(title='Cartesian Coordinate System')

#instructions for manipulating the 3D scene
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.
""")

#draw x, y, z axes
L=15 #length of axes
sw=L/100 #shiftwidth of axes
xaxis=arrow(pos=(-L/2,0,0), axis=(L,0,0), shaftwidth=sw)
yaxis=arrow(pos=(0,-L/2,0), axis=(0,L,0), shaftwidth=sw)
zaxis=arrow(pos=(0,0,-L/2), axis=(0,0,L), shaftwidth=sw)

#draw unit vectors
xhat=arrow(pos=(0,0,0), axis=(1,0,0), shaftwidth=2*sw, color=color.orange)
yhat=arrow(pos=(0,0,0), axis=(0,1,0), shaftwidth=2*sw, color=color.orange)
zhat=arrow(pos=(0,0,0), axis=(0,0,1), shaftwidth=2*sw, color=color.orange)
#define a vector
r=vector(3,4,5)
#draw the vector
rarrow=arrow(pos=(0,0,0), axis=r, shaftwidth=sw,
             color=color.yellow)
rxarrow=arrow(pos=(0,0,0), axis=(r.x,0,0),
              shaftwidth=2*sw, color=color.red)
ryarrow=arrow(pos=rxarrow.axis, axis=(0,r.y,0), 
              shaftwidth=2*sw, color=color.green)
rzarrow=arrow(pos=ryarrow.pos+ryarrow.axis, axis=(0,0,r.z),
              shaftwidth=2*sw, color=color.blue)
In [ ]:
 
In [ ]: