From: Bruce S. <Bru...@nc...> - 2009-01-17 04:54:36
|
It's affected by how the user has zoomed. Here is a calculation that gives you what you seem to be asking for: from visual import * box(pos=(-5,0,0)) box(pos=(5,0,0)) show = label() #scene.range = 100 # with this, initial label is 200 (+/-100) while 1: rate(50) d = mag(scene.mouse.camera-scene.center) w = 2*d*tan(0.5*scene.fov) show.text = "%.1f" % w Bruce Sherwood Joe Heafner wrote: >> Is there a way, e.g. a function, to return the width of a VPython >> scene in real life units independent of what's displayed in the scene? >> For example, if I'm modeling Sun and Earth and I have them on opposite >> sides of a scene, can I obtain the scene's width (~ 1.5e11 m) with a >> function call? scene.width gives the width in pixels. I'm trying to >> take the drudgery out of manually calculating scale factors for >> displaying arrows. >> >> Joe Heafner |