From e40ab41ae226e257d57a73c69d9bdd8d19f64cb5 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 2 Apr 2016 15:56:38 +0200 Subject: Better UI (E/H switching). --- src/physics.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/physics.c') 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); } -- cgit