From 857b9974b7a8e89016357cc91ca4a37561ead7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Mon, 11 Jan 2021 11:29:19 -0300 Subject: Refactor Poly --- src/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index e5e4112..bd7e1a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,12 +14,10 @@ use sdl2::keyboard::Keycode; use sdl2::rect::Rect; fn main() { - //let a = Lerp::new(vec![2.0, -2.0, 2.0]); - //let b = Lerp::new(vec![-1.0, 1.0, 2.0]); - //let pa = lerp::lp(a); - //let pb = lerp::lp(b); - let pa = vec![1.0, 5.0, -2.0]; - let pb = vec![5.0, -4.0, 0.0]; + let a = Lerp::new(vec![2.0, -2.0, 2.0]); + let b = Lerp::new(vec![-1.0, 1.0, 2.0]); + let pa = lerp::lp(a); + let pb = lerp::lp(b); let p = poly::gcd(&pa, &pb); let sdl_context = sdl2::init().unwrap(); @@ -49,9 +47,9 @@ fn main() { let s = -600.0 / 10.0; let k = 600.0 / 2.0; for t in -800..800 { - let x = k + s * poly::eval_poly(&pa, t as Number / 100.0); - let y = k + s * poly::eval_poly(&pb, t as Number / 100.0); - let z = k + s * poly::eval_poly(&p, t as Number / 100.0); + let x = k + s * pa.eval(t as Number / 100.0); + let y = k + s * pb.eval(t as Number / 100.0); + let z = k + s * p.eval(t as Number / 100.0); canvas.set_draw_color(Color::RGB(180, 20, 20)); canvas.fill_rect(Rect::new(400 + t, x as i32, 5, 5)).unwrap(); canvas.set_draw_color(Color::RGB(20, 180, 20)); -- cgit v1.2.3