The quick answer to "numpy in GlowScript" is "no". GlowScript
(glowscript.org) is necessarily written in JavaScript, and GlowScript
user programs are necessarily written in JavaScript (or CoffeeScript,
which compiles to JavaScript). JavaScript is slower than C++ but
considerably faster than Python. To my knowledge, there is no
possibility for something like numpy, which runs at the speed of C.
However, here is the stars program in GlowScript, a program which is
very similar to the gas program:
http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Stars
(You need to enable WebGL in your browser; see the Help at glowscript.org.)
As you see, it runs adequately fast. However, if you examine the code,
you'll see that David Scherer pulled some unintuitive tricks to get
the speed to be adequate. In fairness, you might say that the use of
numpy in the VPython demo programs stars.py and gas.py is also pretty
unintuitive.
Another speed issue to consider is that because GlowScript uses WebGL,
which requires the use of modern GPU-type graphics cards, many kinds
of graphics can be significantly faster than in VPython, which
currently uses GPUs only optionally, for textures. I've been dreaming
of a VPython+ that would also require the use of a modern graphics
card.
I just released GlowScript 1.0 which includes some major new
capabilities. A particularly interesting example is a pulse running
along a rug:
http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Rug
For another capability that goes beyond VPython, here is transparency
done right:
http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Transparency
In VPython, transparent objects are sorted by their pos attribute,
with the result that intersecting transparent objects cannot be
displayed correctly. I implemented "depth peeling" in GlowScript which
uses the GPUs to do pixel-level sorting. Here are the details:
http://www.khronos.org/message_boards/viewtopic.php?f=44&t=4905
Bruce Sherwood
Post by K.-Michael AyeDear all,
I was wondering if the good old VPython gas simulation that uses numpy
so efficiently will run as nicely in Glowscript? Does Glowscript offer
efficient arrays?
Best regards,
Michael