Page 1 of 1

### Custumizing physics ?

Posted: Mon May 02, 2016 9:59 am
Hi everyone !

I'm a beginner bullet user, and I'm trying to figure out how to get the best out of it for a simulation that I'm building. Like a lot of beginners, I'm having a few issues with accuracy and simulations blowing. It's part of the fun

I'm trying to simulate orbit. So far, nothing to hard. The thing is, that some extreme values, or a too big timestep can easily break the "standard" method of calculating the gravity force (F=G*m1*m2/R^2) on each timestep. Since you're revolving around a body, the direction of the force varies continuously, but since you're applying a single fixed force for the duration of a timestep, you might either drift slowly to a different orbit geometry, or (that's the fun one) you might reach escape velocity just because of the way the integrator did it's job over the course of one timestep which wasn't accurate enough (too long) and the resulting force too big.

I hope what I'm saying is understandable enough...

Anyways, since orbiting is something you might want to do for a long time, the more time passes, the more your orbit parameters change when they're supposed to be completely stable in an ideal environment.

So I've had an idea... instead of using a force to make a lookalike orbit that'll always be unstable, why not take another approach: the orbit could be "plotted" from the orbital parameters (easy enough) and then other forces (like a thruster) be computed the "normal" way.

This brings me to my question(s):
- What shall I be implementing ? a custom solver ? a custom constraint ? a custom integrator ? None of those ?
- Is it really bad practice to feed a body with a position on each step ? could this help me solve this ?

I understand that all this seems a little confused, bear with me...

Cheers,
Marc.

### Re: Custumizing physics ?

Posted: Mon May 02, 2016 12:03 pm
You can theoretically make your own custom solver, but that's a PhD topic's worth of work

For your particular needs, it sounds like you would be better off using smaller time steps with bullet, or moving to a more traditional astronomical multibody method. After all, it seems like most of your stuff will be unconstrained motion, so it's far easier to simply integrate it. If you want to take care of collisions too, you could always switch to bullet when you're close enough to something for collisions to happen (and the body pair approximation is fine since the two bodies will be so close that majority of motion is determined by the two collision bodies rather than everything else too)

### Re: Custumizing physics ?

Posted: Mon May 02, 2016 2:18 pm
well, mixing my own integrator with bullet for collisions, I think I might end up with something a little too tricky.

The funny thing about orbits is that the slightest error at point A, can put me several hundreds of kilometers away once I reach point B after a long period of time. This long period of time might just be one half orbit time away, doesn't help

Also, I could do shorter timesteps, but I don't know yet how demanding a step will be in the final app. So I can't really say how small I can go which prevents me from defining what an acceptable error would be.

Alternative idea: I keep my call to applyForce with the result of F=G*m1*m2/R^2, and for each step, I calculate what the exact position should be and compensate for the error (integrating the compensation to the call to applyForce). I should be able to do the math, and it would keep me on the right orbit.