use nalgebra::Complex;
use num_traits::Float;
use crate::Attractor;
#[derive(Debug, Clone, Copy)]
pub struct Tinkerbell<T> {
a: T,
b: T,
c: T,
d: T,
}
impl<T> Tinkerbell<T> {
#[inline]
pub const fn new(a: T, b: T, c: T, d: T) -> Self {
Self { a, b, c, d }
}
}
impl<T: Float + Copy> Attractor<T> for Tinkerbell<T> {
#[inline]
fn iterate(&self, p: Complex<T>) -> Complex<T> {
let x = p.re;
let y = p.im;
Complex::new(
x * x - y * y + self.a * x + self.b * y,
T::from(2.0).unwrap() * x * y + self.c * x + self.d * y,
)
}
}