Render just the B field: it gives a better visualization here

This commit is contained in:
2020-07-24 23:39:07 -07:00
parent 2e92980113
commit 1d9aa738ac
2 changed files with 18 additions and 3 deletions

View File

@@ -8,7 +8,10 @@ fn main() {
let mut step = 0u64; let mut step = 0u64;
loop { loop {
step += 1; step += 1;
state.impulse_ey(50, 50, 50f32 * ((step as f64)*0.1f64).sin() as f32); let imp = 50.0 * ((step as f64)*0.05).sin() as f32;
state.impulse_ex(50, 50, imp);
state.impulse_ey(50, 50, imp);
//state.impulse_bz(50, 50, imp / 3e8f32);
Renderer.render(&state); Renderer.render(&state);
state.step(); state.step();
thread::sleep(time::Duration::from_millis(33)); thread::sleep(time::Duration::from_millis(33));

View File

@@ -33,6 +33,15 @@ fn norm_color(v: f32) -> u8 {
(v * 64.0 + 128.0).max(0f32).min(255f32) as u8 (v * 64.0 + 128.0).max(0f32).min(255f32) as u8
} }
fn curl(x: f32, y: f32) -> f32 {
let c = x * y;
if c >= 0f32 {
c.sqrt()
} else {
-(-c).sqrt()
}
}
impl ColorTermRenderer { impl ColorTermRenderer {
pub fn render(&self, state: &SimState) { pub fn render(&self, state: &SimState) {
let mut buf = String::new(); let mut buf = String::new();
@@ -42,8 +51,11 @@ impl ColorTermRenderer {
let cell = state.get(x, y); let cell = state.get(x, y);
//let r = norm_color(cell.bz() * consts::C); //let r = norm_color(cell.bz() * consts::C);
let r = 0; let r = 0;
let g = norm_color(cell.ex()); let b = 0;
let b = norm_color(cell.ey()); //let g = norm_color(cell.ex());
//let b = norm_color(cell.ey());
//let g = norm_color(curl(cell.ex(), cell.ey()));
let g = norm_color(cell.bz() * 3.0e8);
write!(&mut buf, "{}", RGB(r, g, b).paint(square)); write!(&mut buf, "{}", RGB(r, g, b).paint(square));
} }
write!(&mut buf, "\n"); write!(&mut buf, "\n");