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)
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
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,
yhat=arrow(pos=(0,0,0), axis=(0,1,0), shaftwidth=2*sw,
zhat=arrow(pos=(0,0,0), axis=(0,0,1), shaftwidth=2*sw,
#define a vector
#draw the vector
rarrow=arrow(pos=(0,0,0), axis=r, shaftwidth=sw,
rxarrow=arrow(pos=(0,0,0), axis=(r.x,0,0),
ryarrow=arrow(pos=rxarrow.axis, axis=(0,r.y,0), 
rzarrow=arrow(pos=ryarrow.pos+ryarrow.axis, axis=(0,0,r.z),
In [ ]:
In [ ]: