summaryrefslogtreecommitdiff
path: root/src/main/Accelerator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/Accelerator.h')
-rw-r--r--src/main/Accelerator.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/Accelerator.h b/src/main/Accelerator.h
index c2df021..2c096fd 100644
--- a/src/main/Accelerator.h
+++ b/src/main/Accelerator.h
@@ -91,6 +91,19 @@ public:
/** Fait évoluer l'accélérateur d'un lapse de temps dt. */
void step(double dt) {
+ for (int i = 0; i < particleCollec.size(); ++i) {
+ Particle& particle = *(particleCollec[i]);
+ particle.applyMagneticForce(particle.getElement()->magneticFieldAt(particle.getPosition()), dt);
+
+ Vector3D a = particle.getForce() / (particle.getGamma() * particle.getMass());
+ particle.setVelocity(particle.getVelocity() + a * dt);
+ }
+
+ for (int i = 0; i < particleCollec.size(); ++i) {
+ Particle& particle = *(particleCollec[i]);
+ particle.setPosition(particle.getPosition() + particle.getVelocity() * dt);
+ particle.setForce(Vector3D::Null);
+ }
}