summaryrefslogtreecommitdiff
path: root/src/physics.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2016-04-02 15:56:38 +0200
committerPaweł Redman <pawel.redman@gmail.com>2016-04-02 15:56:38 +0200
commite40ab41ae226e257d57a73c69d9bdd8d19f64cb5 (patch)
tree9f2e4af0f58b6db4ae850939999c642357301003 /src/physics.c
parentf8420e0a46e1069220dcd642bca30c3fcb8c1b91 (diff)
Better UI (E/H switching).
Diffstat (limited to 'src/physics.c')
-rw-r--r--src/physics.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/physics.c b/src/physics.c
index 04c655c..7926478 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -34,7 +34,6 @@ void phy_sim_reset(phy_sim *sim)
sim->time = 0;
sim->running = false;
-
sim->frame_index = get_time();
}
@@ -47,11 +46,11 @@ int phy_sim_create(phy_sim *sim)
fi = &sim->field_info;
- fi->width = 50;
- fi->height = 50;
- fi->depth = 50;
+ fi->width = 100;
+ fi->height = 100;
+ fi->depth = 100;
fi->spacing = 1.5e10f / max3(fi->width, fi->height, fi->depth);
- sim->time_delta = 0.1;
+ sim->time_delta = 0.2;
fi->xstr = 3;
fi->ystr = fi->xstr * fi->width;
@@ -184,7 +183,8 @@ void phy_sim_add_sources_E(phy_sim *sim)
z = fi->depth / 2;
E = sim->fields[2].E + z * fi->zstr + y * fi->ystr + x * fi->xstr;
- E[0] += exp(-0.1f * pow(sim->time - 5.0f, 2)) * 5;
+ E[0] += sin(sim->time * 0.5) *
+ exp(-0.1f * pow(sim->time - 3.0f, 2)) * 50;
}
void phy_sim_add_sources_H(phy_sim *sim)
@@ -198,13 +198,15 @@ void phy_sim_add_sources_H(phy_sim *sim)
z = fi->depth / 2;
H = sim->fields[2].H + z * fi->zstr + y * fi->ystr + x * fi->xstr;
- H[1] -= exp(-0.1f * pow(sim->time - 4.5f, 2)) * 5;
+ H[1] -= exp(-0.1f * pow(sim->time - 5.0f - sim->time_delta / 2, 2)) * 5;
}
void phy_sim_step(phy_sim *sim) {
phy_field_info *fi = &sim->field_info;
phy_field_em *fields = sim->fields, tmp;
+ int64_t start_time;
+ start_time = get_time();
phy_sim_step_E(fi, sim->field_mu, sim->time_delta,
fields[2].E, fields[0].E, fields[1].H);
@@ -222,7 +224,8 @@ void phy_sim_step(phy_sim *sim) {
memcpy(fields + 2, &tmp, sizeof(phy_field_em));
sim->time += sim->time_delta;
- sim->frame_index = get_time();
+ sim->frame_index = get_time(); // for renderer
+ sim->step_real_time = get_time() - start_time;
SDL_mutexV(sim->rotate_lock);
}