-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.cpp
More file actions
36 lines (28 loc) · 930 Bytes
/
integration.cpp
File metadata and controls
36 lines (28 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Florian Probst
// E-Mail: probstf@informatik.uni-freiburg.de / derbalvald@gmail.com
//
#include "integration.h"
// In these functions I assume that particles positions and velocities are still the old ones.
// but the accelerations are the new ones.
void euler(Particles &particles, double dt)
{
particles.positions += particles.velocities * dt;
particles.velocities += particles.accelerations * dt;
}
void implicit_euler(Particles &particles, double dt)
{
particles.velocities += particles.accelerations * dt;
particles.positions += particles.velocities * dt;
}
void verlet_step1(Particles &particles, double dt)
{
particles.positions += particles.velocities * dt + 0.5 * particles.accelerations * dt * dt;
}
void verlet_step2(Particles &particles, double dt)
{
particles.velocities += (0.5 * particles.accelerations * dt);
}
void runge_kutta_4th_order(Particles &particles, double dt)
{
}