diff options
author | rodri <rgl@antares-labs.eu> | 2021-09-25 09:56:42 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-09-25 09:56:42 +0000 |
commit | 265cf72ccfc4922bc96a9e8d265d19a0da96ca34 (patch) | |
tree | 215807d702400900a9211e2cad99993b566ce53d /physics.c | |
parent | 5c3edc3ecc7da495f4eab6de4562e9a6157c9b04 (diff) | |
download | musw-265cf72ccfc4922bc96a9e8d265d19a0da96ca34.tar.gz musw-265cf72ccfc4922bc96a9e8d265d19a0da96ca34.tar.bz2 musw-265cf72ccfc4922bc96a9e8d265d19a0da96ca34.zip |
use semi-implicit euler for bullet dynamics.
Diffstat (limited to 'physics.c')
-rw-r--r-- | physics.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -136,6 +136,18 @@ evalu(Universe *u, Particle *p0, double t, double Δt, Derivative *d, Point2 (*a } static void +euler1u(Universe *u, Particle *p, double t, double Δt) +{ + static Derivative ZD = {0}; + Derivative d; + + d = evalu(u, p, t, Δt, &ZD); + + p->v = addpt2(p->v, mulpt2(d.dv, Δt)); + p->p = addpt2(p->p, mulpt2(p->v, Δt)); +} + +static void rk4u(Universe *u, Particle *p, double t, double Δt, Point2 (*acc)(Universe*,Particle*,double)) { static Derivative ZD = {0}; @@ -163,6 +175,6 @@ integrateu(Universe *u, double t, double Δt) rk4u(u, &u->ships[i], t, Δt, accelship); for(j = 0; j < nelem(u->ships[i].rounds); j++) if(u->ships[i].rounds[j].fired) - rk4u(u, &u->ships[i].rounds[j], t, Δt, accelbullet); + euler1u(u, &u->ships[i].rounds[j], t, Δt, accelbullet); } } |