+line-handled
This commit is contained in:
parent
ebfd39751e
commit
d1db8958ca
25
src/ex.rs
25
src/ex.rs
|
@ -58,6 +58,31 @@ pub fn dumbbell(a: f64, p: f64) -> impl Fn(f64) -> [f64; 2] {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn line_handled(a: f64) -> impl Fn(f64) -> [f64; 2] {
|
||||
let ap2 = a + 2.0;
|
||||
|
||||
move |t: f64| {
|
||||
if t <= 0.25 {
|
||||
let tm4 = t * 4.0;
|
||||
let tt2pi = tm4 * TAU;
|
||||
let (ttsin, ttcos) = tt2pi.sin_cos();
|
||||
[ttcos, ttsin]
|
||||
} else if t <= 0.5 {
|
||||
// start at (1, 0)
|
||||
let tm4 = (t - 0.25) * 4.0;
|
||||
[1.0 + tm4 * a, 0.0]
|
||||
} else if t <= 0.75 {
|
||||
let tm4 = 1.5 - (t - 0.5) * 4.0;
|
||||
let tt2pi = tm4 * TAU;
|
||||
let (ttsin, ttcos) = tt2pi.sin_cos();
|
||||
[ap2 + ttcos, ttsin]
|
||||
} else {
|
||||
let tm4 = 1.0 - (t - 0.75) * 4.0;
|
||||
[1.0 + tm4 * a, 0.0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ellipse(a: f64, b: f64) -> impl Fn(f64) -> [f64; 2] {
|
||||
move |t: f64| {
|
||||
let cdat = circle(t);
|
||||
|
|
|
@ -13,6 +13,7 @@ pub enum SelectExample {
|
|||
CassiniAstroidTsq { ca: f64, cc: f64, aa: f64 },
|
||||
|
||||
Dumbbell { a: f64, p: f64 },
|
||||
LineHandled { a: f64 },
|
||||
Ellipse { a: f64, b: f64 },
|
||||
Lemniskate { a: f64 },
|
||||
CirclePow { k: f64 },
|
||||
|
@ -46,6 +47,9 @@ impl SelectExample {
|
|||
Self::Dumbbell { a, .. } => {
|
||||
*a += l;
|
||||
}
|
||||
Self::LineHandled { a } => {
|
||||
*a += l;
|
||||
}
|
||||
Self::Ellipse { a, b } => {
|
||||
*a /= 1.0 + l;
|
||||
*b *= 1.0 + l;
|
||||
|
@ -84,6 +88,7 @@ impl SelectExample {
|
|||
Box::new(move |t: f64| x(t * t))
|
||||
}
|
||||
Self::Dumbbell { a, p } => Box::new(ex::dumbbell(a, p)),
|
||||
Self::LineHandled { a } => Box::new(ex::line_handled(a)),
|
||||
Self::Ellipse { a, b } => Box::new(ex::ellipse(a, b)),
|
||||
Self::Lemniskate { a } => Box::new(move |t: f64| ex::lemniskate(t, a)),
|
||||
Self::CirclePow { k } => Box::new(ex::circle_pow(k)),
|
||||
|
|
Loading…
Reference in a new issue