summaryrefslogtreecommitdiff
path: root/src/lerp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lerp.rs')
-rw-r--r--src/lerp.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lerp.rs b/src/lerp.rs
index 222671f..1501d0f 100644
--- a/src/lerp.rs
+++ b/src/lerp.rs
@@ -4,6 +4,7 @@ use crate::poly::Poly;
pub enum Lerp {
Node(Box<Lerp>, Box<Lerp>),
Leaf(Number, Number),
+ Just(Number)
}
impl Lerp {
@@ -13,8 +14,8 @@ impl Lerp {
fn new_s(v: &[Number]) -> Box<Lerp> {
match v.len() {
- 0 => Box::new(Lerp::Leaf(0.0, 0.0)),
- 1 => Box::new(Lerp::Leaf(v[0], v[0])),
+ 0 => Box::new(Lerp::Just(0.0)),
+ 1 => Box::new(Lerp::Just(v[0])),
2 => Box::new(Lerp::Leaf(v[0], v[1])),
_ => Box::new(Lerp::Node(
Lerp::new_s(&v[0..v.len() - 1]),
@@ -26,6 +27,7 @@ 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);