VPython Architecture
VPython Architecture
Bruce Sherwood
Professor emeritus, Department of Physics
North Carolina State University
Ruth Chabay
Professor emerita, Department of Physics
North Carolina State University
Empowering Nonexpert Programmers
Browser
user program
VPython with Jupyter Notebook
Local server
Browser
Python
GlowScript
vpython graphics
module JavaScript
library
process
Jupyter browser
communication
other Python
modules WebGL notebook
user program
Web VPython:
Compilation Details
Operator Post-
JavaScript
overloading processing
Executable
Operator Overloading:
How Vector Addition Works
• Using the PaperScript library with the Acorn parser of JavaScript,
convert
a + b => a[‘+’](b)
• Number.prototype['+'] = function(r) {
return (r instanceof vec) ? add_error() : this + r }
• vec.prototype['+'] = function(r) {
return (r instanceof vec) ?
new vec(this.x + v.x, this.y + v.y, this.z + v.z) add_error() }
Rendering of 3D images
Web page
Animation Loop