This commit is contained in:
Alain Zscheile 2023-12-28 14:13:14 +01:00
parent d87ab053cb
commit 42896ae4bc
2 changed files with 17 additions and 0 deletions

View file

@ -78,6 +78,20 @@ pub fn stadion(t: f64, gap: f64) -> [f64; 2] {
}
}
pub fn square(t: f64) -> [f64; 2] {
let t4 = t * 4.0;
let (a, b) = if t < 0.25 {
(t4, 0.0)
} else if t < 0.5 {
(1.0, t4 - 1.0)
} else if t < 0.75 {
(3.0 - t4, 1.0)
} else {
(0.0, 4.0 - t4)
};
[a, b]
}
pub fn wobbly(t: f64, wob: u32) -> [f64; 2] {
let tt2pi = t * core::f64::consts::TAU;
let (ttsin, ttcos) = tt2pi.sin_cos();

View file

@ -21,6 +21,7 @@ pub enum SelectExample {
Spiral1D { k: u32 },
Circle,
Square,
Intersect8,
Intersect8pp,
}
@ -48,6 +49,7 @@ impl SelectExample {
Self::Spiral { .. }
| Self::Spiral1D { .. }
| Self::Circle
| Self::Square
| Self::Intersect8
| Self::Intersect8pp => {
panic!("offsetting not supported for this example")
@ -69,6 +71,7 @@ impl SelectExample {
Self::Spiral { k } => Box::new(ex::spiral(k)),
Self::Spiral1D { k } => Box::new(ex::spiral_1d(k)),
Self::Circle => Box::new(ex::circle),
Self::Square => Box::new(ex::square),
Self::Intersect8 => Box::new(ex::intersect_eight),
Self::Intersect8pp => Box::new(ex::intersect_8pp),
}