spiral: use cosine for dyanmic scale

This commit is contained in:
Alain Zscheile 2023-12-08 00:29:32 +01:00
parent 32b55ed344
commit bb63d86a8c

View file

@ -143,9 +143,8 @@ pub fn cassini_astroid(ca: f64, cc: f64, aa: f64) -> impl Fn(f64) -> [f64; 2] {
pub fn spiral(k: u32) -> impl Fn(f64) -> [f64; 2] {
let x2pi = (k as f64) * core::f64::consts::TAU;
move |t: f64| {
let tstretch = t - 0.5;
let tstretch = tstretch * tstretch;
let ttcos = (t * core::f64::consts::TAU).cos();
let (ttxsin, ttxcos) = (t * x2pi).sin_cos();
[tstretch * ttxcos, tstretch * ttxsin]
[ttcos * ttxcos, ttcos * ttxsin]
}
}