summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-09 19:57:43 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-09 19:59:36 -0300
commit6d356f0c681cb2bb0f26d848ed467f65c49769a5 (patch)
tree34ad6c6ba0af2fa29f6cb2e08373ffa62bc35941 /src/main.rs
parent9724f0d0fe318615e4ed79b1600dd4557a2378eb (diff)
downloadbezier-6d356f0c681cb2bb0f26d848ed467f65c49769a5.tar.gz
bezier-6d356f0c681cb2bb0f26d848ed467f65c49769a5.zip
Implement polynomial gcd
This was done to find the common roots between two polynomials.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 13f13da..8831976 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -23,6 +23,7 @@ fn main() {
let b = Lerp::new(vec![400.0, 140.0, 500.0, 300.0]);
let pa = poly::lp(a);
let pb = poly::lp(b);
+ let p = poly::gcd(&pa, &pb);
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
@@ -51,10 +52,13 @@ fn main() {
for t in 0..800 {
let x = eval_poly(&pa, t as Number / 800.0);
let y = eval_poly(&pb, t as Number / 800.0);
+ let z = eval_poly(&p, t as Number / 800.0);
canvas.set_draw_color(Color::RGB(180, 20, 20));
canvas.fill_rect(Rect::new(t, x as i32, 5, 5)).unwrap();
canvas.set_draw_color(Color::RGB(20, 180, 20));
canvas.fill_rect(Rect::new(t, y as i32, 5, 5)).unwrap();
+ canvas.set_draw_color(Color::RGB(20, 20, 180));
+ canvas.fill_rect(Rect::new(t, z as i32, 5, 5)).unwrap();
}
canvas.present();