Problem with camera.follow on high velocitys

19 views
Skip to first unread message

Avedis Neehus

unread,
Feb 10, 2018, 12:34:08 PM2/10/18
to VPython-users
Setting camera.follow to follow an object with large displacement values results in the object deforming and even disappearing. The behavior can be reproduced with the following:

from vpython import *

ball = sphere()
scene.camera.follow(ball)
scene.autoscale = 0

vel = vector(10**4,0,0)

while 1:
    rate(30)
    ball.pos += vel

Rotating the scene seems to aggravate the issue. 

Bruce Sherwood

unread,
Feb 10, 2018, 3:54:32 PM2/10/18
to VPython-users
I think it may not possible to fix this. It appears to me that when the ball's distance from the origin gets to be over a million, the GPU-based WebGL graphics library has problems. I'll look into this more, but I'm not sure it's possible to make this work over such an enormous range.

Two suggestions: Perhaps you can scale the problem in some way to avoid such huge changes. Or consider the possibility of keeping the ball fixed in position but continually changing the background, to simulate motion. 

Bruce

Avedis Neehus

unread,
Feb 11, 2018, 11:49:51 AM2/11/18
to vpytho...@googlegroups.com
Thats good to know. I'll scale my problem to avoid this. 

Virenfrei. www.avast.com

--
You received this message because you are subscribed to a topic in the Google Groups "VPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vpython-users/wD3DRbRBTs4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruce Sherwood

unread,
Feb 12, 2018, 11:03:22 AM2/12/18
to VPython-users
There's no problem with having a scene whose range is 1e11, but somehow there's a problem starting from a scene with range = 1 and then trying to follow an object that is moved to x = 1e6.

Kevin Karplus

unread,
Feb 12, 2018, 12:08:49 PM2/12/18
to vpytho...@googlegroups.com
I think that the problem may be related to scaling to integer arithmetic and running into 32-bit limits, though it may just be problems with single-precision floating-point.

Undergraduate Director, Bioengineering and Bioinformatics
Professor of Biomolecular Engineering, University of California, Santa Cruz
Affiliations for identification only.


On Mon, Feb 12, 2018 at 8:03 AM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
There's no problem with having a scene whose range is 1e11, but somehow there's a problem starting from a scene with range = 1 and then trying to follow an object that is moved to x = 1e6.

--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-users+unsubscribe@googlegroups.com.

Bruce Sherwood

unread,
Feb 12, 2018, 2:08:38 PM2/12/18
to VPython-users
It's true that with the existing WebGL it is necessary to send 32-bit floats to the GPU, but I don't think that's the issue, because as I say there's no problem with a huge range, just with changing the range hugely.

Because VPython object attributes may be used in calculations, they are kept as double-precision (64-bit) floats in the CPU, but these are reduced to 32-bit floats when sending information to the GPU. This is of course adequate for rendering purposes; the eye cannot detect nor the screen make a difference of one part in a zillion.

Bruce
Reply all
Reply to author
Forward
0 new messages