Thermotronica / Yes

Dont worry about it
1 stars 0 forks source link

New issue? Heres a tissue #1

Closed Thermotronica closed 3 months ago

Thermotronica commented 6 months ago

[derive(Debug, Clone, Copy)]

struct Complex { real: f64, imag: f64, }

fn to_complex_number(real: f64, imag: f64) -> Complex { Complex { real, imag } }

fn recursive_complex_number(iterations: usize) -> Complex { if iterations == 0 { to_complex_number(1.0, 1.0) } else { let prev = recursive_complex_number(iterations - 1); let (r, i) = (prev.real + prev.imag, prev.real - prev.imag); to_complex_number(r, i) } }

fn main() { let phi = std::f64::consts::PI / 4.0; let iterations = 3;

let recursive = recursive_complex_number(iterations);
let e_iphi = to_complex_number(phi.cos(), phi.sin());

let result = Complex {
    real: recursive.real / e_iphi.real,
    imag: recursive.imag / e_iphi.imag,
};

println!("Result: {:?}", result);
println!("Phase Angle (phi): {}", phi);

}

Thermotronica commented 5 months ago

image

Thermotronica commented 5 months ago

image