From 485a25c0293d407193a7c64655578a06c1046d91 Mon Sep 17 00:00:00 2001 From: numzero Date: Tue, 7 May 2024 15:30:15 +0300 Subject: [PATCH] Use constants --- src/bin/flat.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin/flat.rs b/src/bin/flat.rs index a13b80f..c5e22ad 100644 --- a/src/bin/flat.rs +++ b/src/bin/flat.rs @@ -8,6 +8,9 @@ use crate::boundary::Loop; #[cfg(test)] use approx::assert_abs_diff_eq; +const RAYS_IN_FAN: usize = 101; +const DT: f32 = 0.1; + pub fn main() { let space = Coil { scale: 3.0, @@ -86,7 +89,7 @@ impl SpaceVisual for Inside { impl Rayable for [Box] { fn draw_ray(&self, gc: &mut Vec, base: Vec2, dir: Vec2) { gc.new_path(); - let dt = 1.0; + let dt = DT; let mut s = boundary::Id(0); let mut p = base; let mut v = dir.normalize(); @@ -125,7 +128,7 @@ trait Rayable { fn draw_fan(&self, gc: &mut Vec, base: Vec2, dir: Vec2, spread: f32) { let dir = dir.normalize(); let v = vec2(-dir.y, dir.x); - for y in itertools_num::linspace(-spread, spread, 101) { + for y in itertools_num::linspace(-spread, spread, RAYS_IN_FAN) { self.draw_ray(gc, base, dir + y * v); } } @@ -136,7 +139,7 @@ impl Rayable for T { let dir = self.globalize(base, dir); gc.new_path(); gc.move_to(base.x, base.y); - for pt in trace_iter(self, base, dir, 1.0).take(10000) { + for pt in trace_iter(self, base, dir, DT).take(10000) { gc.line_to(pt.x, pt.y); if pt.abs().cmpgt(Vec2::splat(1000.0)).any() { break;