Objects are 'shaking' in space using big coordinates.

Hello,

I have a problem in Panda3D application where I try to simulate gravity - a body going around another body.

“1.0” for me is considered one meter, and so body (a sphere) has a radius of “10.0” and is going around object (earth) with radius of “6371000.0”, having a mass of

EARTH_MASS = 5.98 * 1000000.0 * 1000000.0 * 1000000.0 * 1000000.0

So it’s big numbers, and the problem is that in the end of all calculations I get few HEAVILY SHAKING objects: space body, two (velocity and gravity visualizers) vectors are shaking, and looks like camera (which is a child of space body) itself shakes also! And they all do that rather asynchronously.

Well, I have some calculation uncertainty - for example, altitude (you can see that printed in console) is moving up and down for a “0.5” units, but as for that “shanking” I guess it’s not the case, since two vector nodepaths has the same “setPos()” as body, and camera is reparented to the body itself. So I could expect to see all of them in exact same place, right?

Please take a look:
vacuum_2010-11-07.zip

I’ve placed “time.sleep()” in every frame to slow down and see it more clearly.

Thank you.

P.S. I’m using Panda3D 1.6.2 in Ubuntu 10.10 32bit.

Graphics cards are not designed to handle the scales found in space which may be the issue you are having at the moment. What I did is separated the simulation and graphics. Simulation is 1 panda unit = 1 meter, but the graphics layer scales the object down instead when it gets over 10,000 units away. The camera can rotate but I move the planets instead of moving the camera. My code is a bit messy but I am more than happy to post it.

Thast’s great idea, croxis, but can “Point3(17725.2, 0, 6.73098e+06)” be already too big? :open_mouth: I mean, magnitude does not reach a million.

talkless. keep in mind we’r also dealing with rotations here. and, when rotations are messing aroudn you always have to translate coordinates with sin and cos on a low level (panda hides that from you). if you change an angle by a tiny little bit. a point rotated in 100thousand units distance would suffer from quite some noticeable error due to rounding.

6.73098e+06 is not too big for computation, but that scale gets too big for graphics cards

Or this “shaking” is due to the fact that your float is getting “imprecise” for big number. Reason: en.wikipedia.org/wiki/Single_pre … int_format -> for big numbers the “lower” parts are cut of