I fetched it thinking it was source code but its a program. My Windows computer is boned, I'll look at it after I'm done reinstalling everything.
Oh, also, while you're playing with it you might throw in atmospheres. Aerodynamic drag is a big deal. Space stations are kept at low altitudes, in the thin upper atmosphere, where the wind drag brings down debris and destroys meteoroids. Much safer. But if they don't supply it with fuel continually, it'll sink and the headwind will destroy it within only half a year.
Modeling stellar orbits
Hmm, atmospheres might be interesting once I get to a more detailed visual representation of these stellar bodies. You'll see what I mean if you open the program haha. Also at the moment my bodies are basically just stars, I'm working to set up a little polymorphic system so that bodies can be either gasseous or solid, and then doing stars and planets like that to give more diversity. That way I could handle collisions differently even if I wanted to. When I get that far, atmospheres will probably be a must. It's a very cool idea.
Quote:Original post by Numsgil
The issue is that when you numerically integrate the motion [...]
You can't really 100% solve this issue, [...]
Two words: variational integrator. The intro chapters to Matt West's Thesis are a good starting point.
The downside is you get an implicit scheme, but that's really not so bad.
Quote:Original post by EmergentQuote:Original post by Numsgil
The issue is that when you numerically integrate the motion [...]
You can't really 100% solve this issue, [...]
Two words: variational integrator. The intro chapters to Matt West's Thesis are a good starting point.
The downside is you get an implicit scheme, but that's really not so bad.
Well, maybe that's a little complicated for a first simple experiment. Anyway, your system won't loose or gain energy if you use a symplectic integrator. A really good simple one is velocity verlet. I've implemented some higher order symplectic integrators too, and they did a really good job.
ps. Haven't forgotten about those code samples - still looking for them :-)
Cheers,
Mike
Alright, I've got velocity verlet integration in place instead of Euler's integration. I'm noticing some strange behavior however. My major stars are being thrown around a lot more by their minor stars than they used to be. Maybe this is accurate? I don't really know. I just see them moving around with more speed now...
I saw that there's a similar integration technique for position that does not use velocity at all. I tried implementing and switching between updating position by velocity, and by this new verlet integration and saw pretty much the same thing. Should my major stars be moving more with velocity verlet integration than they were with Euler's?
In case I'm just messing up, here is my new code for updating everything:
EDIT: I've just found this page about velocity verlet integration: Link
In that page, they talk about a technique that looks awfully similar to my original Euler method, only they update velocity by half of the delta time, then update the position, and then update the velocity again by the other half delta. Is this better than the verlet technique I am currently using? They claim the accuracy and error is better.
[Edited by - ChugginWindex on November 18, 2010 11:19:11 AM]
I saw that there's a similar integration technique for position that does not use velocity at all. I tried implementing and switching between updating position by velocity, and by this new verlet integration and saw pretty much the same thing. Should my major stars be moving more with velocity verlet integration than they were with Euler's?
In case I'm just messing up, here is my new code for updating everything:
//update velocity using velocity verlet integration based on the accelerations of both this time and last timestep auto lastAccel = m_lastAppliedForces; lastAccel.x /= m_mass; lastAccel.y /= m_mass; m_velocity.x += 0.5 * (lastAccel.x + m_appliedForces.x / m_mass) * timeDelta; m_velocity.y += 0.5 * (lastAccel.y + m_appliedForces.y / m_mass) * timeDelta; m_position.x += m_velocity.x * timeDelta; m_position.y += m_velocity.y * timeDelta; //since this is called at the end of all interactions on the body this frame, clear out the forces //after updating them as the last timestep's forces so they can be recalculated each frame m_lastAppliedForces.x = m_appliedForces.x; m_lastAppliedForces.y = m_appliedForces.y; m_appliedForces.x = 0; m_appliedForces.y = 0;
EDIT: I've just found this page about velocity verlet integration: Link
In that page, they talk about a technique that looks awfully similar to my original Euler method, only they update velocity by half of the delta time, then update the position, and then update the velocity again by the other half delta. Is this better than the verlet technique I am currently using? They claim the accuracy and error is better.
[Edited by - ChugginWindex on November 18, 2010 11:19:11 AM]
Quote:Original post by h4tt3n
ps. Haven't forgotten about those code samples - still looking for them :-)
From me? Of a variational integrator? If so, then I had forgotten, but I wouldn't mind digging one up...
Quote:Original post by EmergentQuote:Original post by h4tt3n
ps. Haven't forgotten about those code samples - still looking for them :-)
From me? Of a variational integrator? If so, then I had forgotten, but I wouldn't mind digging one up...
Oh, that was for ChugginWindex - I promised him some code samples. But hey, throw in whatever you got as well. I'd like to see how that variational integrator works, haven't played around with those yet. :-)
cheers,
Mike
Ok, here's something...
http://www.jernmager.dk/stuff/gravity_code_examples.zip
They're very simple and commented line by line. Sorry for the basic dialect - I really should redo these in c++ once I get the time :-/
Cheers,
Mike
http://www.jernmager.dk/stuff/gravity_code_examples.zip
They're very simple and commented line by line. Sorry for the basic dialect - I really should redo these in c++ once I get the time :-/
Cheers,
Mike
Oh hey! I stumbled across those myself not too long ago. The methods you used seemed very similar to what I had at the time.
I got around to running this. It's a really fun toy! I wish I could center on an entity; they drift around.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement