Jupyter VPython 0.3.8 now with attach_trail and attach_arrow

117 views
Skip to first unread message

Bruce Sherwood

unread,
Apr 25, 2016, 5:30:04 PM4/25/16
to VPython-users
Jupyter VPython 0.3.8 now supports attach_trail and attach_arrow, and fixes a problem with compound triangles or quads.

At the following location in the GlowScript VPython Help, also accessible from "Work with 3D Objects > Attach a Trail or Arrow", are links to the attach_trail and attach_arrow objects:


attach_trail is a somewhat more powerful version of the make_trail mechanism. It includes the capability of specifying a function to be executed to obtain a position to be added to the trail rather than using the position of an object.

attach_arrow lets you specify that an arrow be continually displayed at the location of a moving object, with a length and direction of an attribute of the moving object, multiplied by an optional scale factor. For example, if s represents a sphere with velocity s.velocity and force acting on it s.force, you can specify that arrows representing the velocity and force vectors be continuously displayed as the sphere moves:

attach_arrow(s, "velocity", scale=10, color=color.green)
attach_arrow(s, "force", scale=0.3, color=color.red)

Bruce Sherwood

unread,
Apr 25, 2016, 5:43:33 PM4/25/16
to VPython-users
Progress: The only significant GlowScript feature not yet available in Jupyter VPython is extrusion (and even the GlowScript extrusion object is pretty rudimentary). 

Also, the Jupyter VPython vector class has been speeded up by using Cython, so that performance in many common situations is comparable to that of Classic VPython. There is not yet an installer for the sped-up version, but work is proceeding on this. The complicating factor is that the faster vector class requires binary versions for Windows and Mac and Linux, and the installer has to install the correct platform-specific binary.

The basic description of Cython is this: You write code in pure Python. Then you "decorate" that code with information such as declaring that the variable "x" will always be a floating-point number. In pure Python x might start out being a floating-point number but later be used to name a sphere object -- Python does "dynamic typing" or variables, which slows down computations because Python has to detect what kind of variable x is, every time it's used.

The decorated program is passed through Cython, which generates a C-language program which must then be compiled. Mac and Linux platforms come with a C compiler, but Windows requires a special installation of a C compiler. In all cases, the installer will come with already compiled binaries and will install the binary appropriate to the particular computer.
Reply all
Reply to author
Forward
0 new messages