Problem with compound_to_world()

12 views
Skip to first unread message

MurrayG

unread,
Feb 11, 2016, 8:00:47 PM2/11/16
to Glowscript Users
Hi there,

I have been having trouble with compound_to_world(). If I run the following program...

-----------------------------------
GlowScript 2.0 VPython

obj1 = cylinder( pos = vec(0,0,0), radius = 0.2, axis = vec(+1,0,0), color = color.yellow )
obj2 = cylinder( pos = vec(0,0,0), radius = 0.2, axis = vec(-1,0,0), color = color.orange )
obj = compound( [obj1, obj2] )
obj.rotate( angle = pi/2, pos = vec(0,0,0), axis=vec(0,0,-1))

world_pos = obj.compound_to_world( vec(1, 0, 0))
print( world_pos)
-----------------------------------

... I get an error message on the second last line saying, "TypeError: up.mag2 is not a function".
What am I doing wrong?

Thanks,
Murray.

Bruce Sherwood

unread,
Feb 11, 2016, 8:34:20 PM2/11/16
to Glowscript Users
Fixed. Thanks much for the report.

The bug was that in GlowScript 1.1, one wrote mag2(vector) or vector.mag2(), but the latter form was changed in GlowScript 2.0 to vector.mag2, as the older form was basically a mistake. The compout_to_world function hadn't been corrected.

I searched for and found other cases of vector.mag() or vector.mag2() and fixed them too.

MurrayG

unread,
Feb 12, 2016, 12:11:01 AM2/12/16
to Glowscript Users
Thanks Bruce,

The problem in my program has been fixed. Thanks for the prompt reply, as well as the awesome program that you have developed.

Murray.
Reply all
Reply to author
Forward
0 new messages