THIS ARTICLE HAS BEEN SUPERSEDED BY THE ARTICLE
“A time line for VPython development”
You are invited to try out GlowScript (“Graphics Library on Web”), an easy to use 3D programming environment inspired by VPython, but which runs in a browser window. GlowScript has been developed by David Scherer (the originator of VPython) and me.
* At glowscript.org, click Example programs to see the kinds of things that VPython can do in a browser. When viewing a list of programs you can click “View” to see the VPython program, or when running a program you can click “View this program” to see the code.
* GlowScript uses the WebGL 3D graphics library that is included in current versions of major web browsers. You must have a modern graphics card with Graphics Processing Units (GPUs). GlowScript even works in browsers on smartphones and tablets.
* To write your own programs, log in (you’ll be asked for a Google login, such as a gmail account).
* Click “Run this program” or press Ctrl-1 to execute your program in the same window, then click “Edit this program” to return to editing.
* Alternatively, while editing press Ctrl-2 to execute your program in a separate window, so that you can view the execution and the program code simultaneously. After making edits, press Ctrl-2 in the editor to run the new program.
* While running a program, click Screenshot to capture a thumbnail image for your program page.
* In the editor, click “Share or export this program” to learn how to let other people run your program.
There is a version system in place that will allow old programs to continue running in the future. The first line of a program you write is automatically created to be “GlowScript X.Y VPython” (where X.Y is the current version number). When a new version comes out, the software for running the older version is retained for use whenever a program with an old version number is encountered.
There is a user forum connected to glowscript.org, where you can describe your experiences or ask for assistance.
WebGL’s emphasis on the use of the Graphics Processing Unit (GPU) available on modern graphics cards makes it possible for GlowScript to do high-quality graphics.
For users of Classic VPython, note that the VPython Help summarizes the main differences between Classic VPython (VPython 6) and GlowScript VPython (and VPyhon 7). Also available there is a Python program for converting Classic VPython programs to the new syntax. VPython 7 uses the GlowScript libraries to render the 3D scenes.
Use of the GlowScript libraries has been implemented by Brian Marks in Trinkets.
If you are new to programming, you may find the Python tutorials at www.codecademy.com very helpful.
Hello, firstly I’d like to say I absolutely love your work, especially glowscript! I don’t have a lot of experience with coding but I’ve been learning a lot. Recently I completed my own Double Pendulum project, which I’d spent many months working on and developing the skills necessary to complete it. Today, I came across the Double Pendulum project that you published under Example Programs, and let me say, I love the complexity! I simplified mine down to just two point masses connected by massless rods. While I was checking yours out I kept looking at the accelerations of the bars and occasionally it would look unnatural at points. Like some force would come out of nowhere to push one of the arms in a weird way. Of course, I get that they are two arms of different lengths and masses, but I still felt it looked off slightly. So I took the liberty of importing your code and adding some features to visualize the energy of the system as a function of time. I found that the total energy of your system isn’t constant over time. It appears that the system occasionally gains and loses energy randomly. I’ve attached a link to the modified version I made of yours as well as my personal double pendulum project if you are at all curious (if you do check it out, apologies for the ugly code, I don’t have much experience). Best and thanks!
Sherwood modified – https://www.glowscript.org/#/user/X9Z3/folder/X9Z3Publications/program/Sherwood-DP-Analysis
My personal project – https://www.glowscript.org/#/user/X9Z3/folder/X9Z3Publications/program/Chaos-Pendulum-PointMass
Thanks for your report. There does indeed seem to be an error in my program, and I haven’t yet figured out what the problem is. I believe that your “Sherwood modified” program incorrectly calculates the energy. Because my pendula are long masses, their rotational kinetic energies are 0.5*I*w**2, where the moment of inertia I is (1/12)*M*L**2 and w is the angular speed. Their translational kinetic energies are 0.5*M*v**2, where v is the speed of the center of mass. Here is what I believe are the correct energy calculations, where pos1 and pos2 are the previous positions, before updating the positions:
dpos1 = bar1.pos-pos1
dpos2 = bar2.pos-pos2
Ktrans1 = .5*M1*mag2(dpos1/dt)
Ktrans2 = .5*M2*mag2(dpos2/dt)
Krot1 = .5*I1*(dtheta1/dt)**2
Krot2 = .5*I2*(dtheta2/dt)**2
PE1 += M1*g*dpos1.y
PE2 += M2*g*dpos2.y
(Hard to interpret with this font. In the calculations of Krot1 and Krot2, the character after “5* is capital i, for moment of inertia.)
I fixed the bug. Here is the corrected version:
I’ve added a graph of the 3 contributors to the total energy (translational kinetic energy, rotational kinetic energy, and gravitational potential energy). The total energy should be but isn’t exactly zero, but it remains very small compared to the other energy terms. Thanks again for pointing out that the program wasn’t working!