+square
This commit is contained in:
parent
d87ab053cb
commit
42896ae4bc
14
src/ex.rs
14
src/ex.rs
|
@ -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] {
|
pub fn wobbly(t: f64, wob: u32) -> [f64; 2] {
|
||||||
let tt2pi = t * core::f64::consts::TAU;
|
let tt2pi = t * core::f64::consts::TAU;
|
||||||
let (ttsin, ttcos) = tt2pi.sin_cos();
|
let (ttsin, ttcos) = tt2pi.sin_cos();
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub enum SelectExample {
|
||||||
Spiral1D { k: u32 },
|
Spiral1D { k: u32 },
|
||||||
|
|
||||||
Circle,
|
Circle,
|
||||||
|
Square,
|
||||||
Intersect8,
|
Intersect8,
|
||||||
Intersect8pp,
|
Intersect8pp,
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ impl SelectExample {
|
||||||
Self::Spiral { .. }
|
Self::Spiral { .. }
|
||||||
| Self::Spiral1D { .. }
|
| Self::Spiral1D { .. }
|
||||||
| Self::Circle
|
| Self::Circle
|
||||||
|
| Self::Square
|
||||||
| Self::Intersect8
|
| Self::Intersect8
|
||||||
| Self::Intersect8pp => {
|
| Self::Intersect8pp => {
|
||||||
panic!("offsetting not supported for this example")
|
panic!("offsetting not supported for this example")
|
||||||
|
@ -69,6 +71,7 @@ impl SelectExample {
|
||||||
Self::Spiral { k } => Box::new(ex::spiral(k)),
|
Self::Spiral { k } => Box::new(ex::spiral(k)),
|
||||||
Self::Spiral1D { k } => Box::new(ex::spiral_1d(k)),
|
Self::Spiral1D { k } => Box::new(ex::spiral_1d(k)),
|
||||||
Self::Circle => Box::new(ex::circle),
|
Self::Circle => Box::new(ex::circle),
|
||||||
|
Self::Square => Box::new(ex::square),
|
||||||
Self::Intersect8 => Box::new(ex::intersect_eight),
|
Self::Intersect8 => Box::new(ex::intersect_eight),
|
||||||
Self::Intersect8pp => Box::new(ex::intersect_8pp),
|
Self::Intersect8pp => Box::new(ex::intersect_8pp),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue