use nalgebra::Complex;
use num_traits::Float;
use crate::Attractor;
#[derive(Debug, Clone, Copy)]
pub struct Ikeda<T> {
u: T,
}
impl<T> Ikeda<T> {
#[inline]
pub const fn new(u: T) -> Self {
Self { u }
}
}
impl<T: Float + Copy> Attractor<T> for Ikeda<T> {
#[inline]
fn iterate(&self, p: Complex<T>) -> Complex<T> {
let x = p.re;
let y = p.im;
let r_squared = x * x + y * y;
let t = T::from(0.4).unwrap() - T::from(6.0).unwrap() / (T::one() + r_squared);
let cos_t = t.cos();
let sin_t = t.sin();
Complex::new(T::one() + self.u * (x * cos_t - y * sin_t), self.u * (x * sin_t + y * cos_t))
}
}