summaryrefslogtreecommitdiff
path: root/src/lerp.rs
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-17 18:17:57 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-17 18:17:57 -0300
commitb25771270f0fd1fe20432ce2c1a671a04bb57a50 (patch)
treefd1cade5f3a69d9acaa8080d6da43b9dd09382d4 /src/lerp.rs
parentbc4d45fa639e32394081f726cbb1f093eb469b0a (diff)
downloadbezier-b25771270f0fd1fe20432ce2c1a671a04bb57a50.tar.gz
bezier-b25771270f0fd1fe20432ce2c1a671a04bb57a50.zip
Refactor function lp into lerp method to_poly
Diffstat (limited to 'src/lerp.rs')
-rw-r--r--src/lerp.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lerp.rs b/src/lerp.rs
index b098f23..818c686 100644
--- a/src/lerp.rs
+++ b/src/lerp.rs
@@ -22,17 +22,17 @@ impl Lerp {
)),
}
}
-}
-pub fn lp(l: Box<Lerp>) -> Poly {
- match *l {
- Lerp::Just(a) => Poly::new(vec![a]),
- Lerp::Leaf(a, b) => Poly::new(vec![a, b - a]),
- Lerp::Node(a, b) => {
- let a = lp(a);
- let b = lp(b);
- let c = &b - &a;
- &a + &(&c * &Poly::new(vec![0.0, 1.0]))
+ pub fn to_poly(self) -> Poly {
+ match self {
+ Lerp::Just(a) => Poly::new(vec![a]),
+ Lerp::Leaf(a, b) => Poly::new(vec![a, b - a]),
+ Lerp::Node(a, b) => {
+ let a = a.to_poly();
+ let b = b.to_poly();
+ let c = &b - &a;
+ &a + &(&c * &Poly::new(vec![0.0, 1.0]))
+ }
}
}
}