Cylinder Axis

11 views
Skip to first unread message

Marc Diesse

unread,
Oct 14, 2016, 12:26:56 PM10/14/16
to Glowscript Users
Hello Glowscript Team and Users,

I noticed something while using GlowScript with Python:

With the cylinder object it says in the documentation the documentation "only the direction of the axis is meaningful, not its magnitude". But I found with
    b = cylinder(pos=vec(0,0,0),size=vec(3,1,1))
    and (after a keypress)
    b.axis = vec(0,1,0)
the lenght along the main axis turned to 1

Greetings
Marc Diesse

Bruce Sherwood

unread,
Oct 14, 2016, 12:40:10 PM10/14/16
to Glowscript Users
Where did you find that documentation, which is incorrect?
Here is the correct information, from Help at GlowScript.org:

axis The axis points from pos to the other end of the cylinder, default = vector(1,0,0). Setting the axis makes length equal to the magnitude of the axis.

length Length of axis and x component of size; default is 1. Setting the length makes the magnitude of the axis equal to the length.

radius The radius of the cylinder, default = 1

size Instead of specifying length and radius, you can set size=vector(length,height,width), which means that the cross section of the cylinder can be elliptical, which is not currently possible in classic VPython. Setting size makes the magnitude of axis be equal to the x component of the size (the length).

Bruce Sherwood

unread,
Oct 14, 2016, 1:10:45 PM10/14/16
to Glowscript Users
Ah. Now I get it. You ferreted out the documentation for programs that start with "GlowScript 2.1 RapydScript" but your own program starts with "GlowScript 2.1 VPython". VPython programs use the RapydScript tranpiler but follow the Classic VPython semantics of having axis and size interact with each other as described above.

I finally realized that this must be the case, because you use RapydScript's "nonlocal" instruction whereas in a preprocessing stage for a VPython program "global" is changed to "nonlocal', so that GlowScript VPython programs using "global" can run also in Jupyter VPython without change.
Reply all
Reply to author
Forward
0 new messages