Sphere radius seems to not be set properly

16 views
Skip to first unread message

Matija Han

unread,
Mar 23, 2016, 10:45:11 PM3/23/16
to VPython-users
Hi,
I pasted the basic bouncy ball sample code into my Jupyter notebook, and it looked wrong as the ball seemed to bounce off thin air above the box. After some investigation, I found the root cause to be the fact that the sphere radius is somehow not handled properly - when set to 1.0, it returns 2.0 when retrieved. Please see the attached screenshot.
Thanks,
Matija
VPython_ball_radius.png

Bruce Sherwood

unread,
Mar 24, 2016, 1:02:41 AM3/24/16
to VPython-users
You're using the experimental ivisual. Execute pip install vpython and execute the following, and you'll get the correct behavior:

from vpython import *
ball = sphere(pos=vector(0,2,0), radius=1, color=color.red)
print(ball.radius)

See the first page of vpython.org for additional information about Jupyter VPython.

Matija Han

unread,
Mar 24, 2016, 11:45:34 PM3/24/16
to VPython-users
That solved it, thanks! For some reason that didn't work the first time - I don't know what I did incorrectly, and how I googled myself into using ivisual instead. I was at first happy to see some output, but was then boggled as to why anyone would make that ball bounce off of thin air and started investigating.

Let me use the opportunity to say this: I learned about VPython through the Podcast.__init__ episode you were in, and it was very timely and serendipitous, as I'm just about to start an introductory course for young aspiring programmers, and VPython is just the thing for that! So, big thanks!!!

Bruce Sherwood

unread,
Mar 25, 2016, 12:40:50 AM3/25/16
to VPython-users
Glad to hear it! Here is the podcast of Ruth Chabay and me talking about VPython:


One of the problems of introducing programming to novices is that, alas, too often the first application is to print "Hello World". BOOOORing. Surely it's got to be more motivating to write a one-line program, box(), and see something in 3D, and rotate and zoom the camera. Moreover, the important notion of an "object", and "instances" of an object, are a whole lot more vivid when you see several boxes and change the "attributes" of these instances of the box class than when objects are introduced through the traditional application of employee records.
Reply all
Reply to author
Forward
0 new messages