Gideros box2d types7/21/2023 I'll take a look at the code you linked to when I have a bit more time, and I'll see if there is an error there or whatnot. And if you can improve a bit on that by using a second order method, why not? It's just worth testing it against an exact solution to see how small you need to make your dt. What you have up there will definitely give you the right answer. But when you just a few satellites around a star/planet, it's not so bad. If you'll have some spare time, I suggest you try writing a galaxy simulation. The algorithms used by NASA can get rather complex because they need to be able to predict motion of asteroids with very high precision.įor a game, that's not as big of a deal until you start having a lot of objects interacting with each other. It's extremely challenging to build a true simulation of gravitational interaction. And there is no general solution to that problem. With gravity, both methods tend to cause energy accumulation over time. So if you ever see a pool simulation where the billiards seem to bounce off faster than they should, and things getting really chaotic when multiple billiards collide, that's probably because the wrong integration method was used. With Forward Euler you tend to end up with energy building up in the system. Basically, if you simulate collision between two objects by pretending that there is a spring between them that starts pushing objects apart as they get closer, Verlet integration is much better as it almost guarantees that energy is conserved. It's really good at conserving energy in harmonic interactions. There is one more advantage of Verlet integration which is responsible for its popularity. They both solve the same problem and both can be equally precise, but the size of the step, usually, has to be smaller with Forward Euler to achieve the same precision. Verlet is second order and Forward Euler is first order. I've already planned to implement some kind of solar storm shot by the player to "eat" the objects it crosses and make your star bigger Edited by grawl PS: Also, if anyone got any idea about a possible gameplay and a way to use the phone captors (accelerometer, inclinometer, screen touch, etc), I'm all ears. Thank you for your answers, I'm looking forward to them. What is the way to calculate the new coordinates of the object's vector once it is inside the star circle of influence ? Is it possible for the objects to achieve stable orbit around the star ? Or will I need to tweak reality a bit ?Ģ. I've got several objects with mass, coordinates (Xo,Yo) and a speed vector defined by its coordinates (Xv,Yv).ġ. I've got a star with mass and a "circle" of influence (we're talking 2D here ), defined as the center (x=0, y=0). I knew I should have been more present in physics class. I'm developping a small smartphone 2D game for my end of year project, and I'm blocked because of my little maths knowledge.
0 Comments
Leave a Reply. |