fix self-intersection of dumbbell curve

This commit is contained in:
Alain Zscheile 2024-01-05 21:11:34 +01:00
parent b74b9e4c7f
commit d1dd84cdfa

View file

@ -48,11 +48,11 @@ pub fn dumbbell(a: f64) -> impl Fn(f64) -> [f64; 2] {
} else if t <= 0.75 {
let tm4 = (t - 0.5) * 4.0;
let t2 = tm4.powi(2);
[-a * tm4, a * t2 * (1.0 - t2).sqrt()]
[-a * tm4, -a * t2 * (1.0 - t2).sqrt()]
} else {
let tm4 = 1.0 - (t - 0.75) * 4.0;
let t2 = tm4.powi(2);
[-a * tm4, -a * t2 * (1.0 - t2).sqrt()]
[-a * tm4, a * t2 * (1.0 - t2).sqrt()]
}
}
}