shared/types/fractal_descriptor.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
use serde::{Deserialize, Serialize};
use crate::types::complex::Complex;
/// General descriptor for a fractal, encompassing different fractal types.
///
/// Attributes:
/// - `fractal_type`: A variant of `FractalType` specifying the type of fractal and its parameters.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FractalDescriptor {
#[serde(flatten)]
pub fractal_type: FractalType,
}
/// Represents the type of fractal to be generated.
///
/// Variants:
/// - `Julia(JuliaDescriptor)`: Represents a Julia fractal with its specific descriptor.
/// - `Mandelbrot(MandelbrotDescriptor)`: Represents a Mandelbrot fractal (currently commented out).
/// - `BurningShip(BurningShipDescriptor)`: Represents a BurningShip fractal with its specific descriptor.
/// - `...`: Placeholder for additional fractal types.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum FractalType {
Julia(JuliaDescriptor),
IteratedSinZ(IteratedSinZDescriptor),
Mandelbrot(MandelbrotDescriptor),
NewtonRaphsonZ3(NewtonRaphsonZ3Descriptor),
NewtonRaphsonZ4(NewtonRaphsonZ4Descriptor),
BurningShip(BurningShipDescriptor),
}
/// Describes parameters specific to a Julia fractal.
///
/// Attributes:
/// - `c`: A `Complex` number representing the constant parameter of the Julia set.
/// - `divergence_threshold_square`: The square of the divergence threshold. Points whose magnitude square exceeds this threshold are considered to diverge.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct JuliaDescriptor {
pub c: Complex,
pub divergence_threshold_square: f64,
}
/// Describes parameters specific to a Mandelbrot fractal.
///
/// Attributes:
/// - `c`: A `Complex` number representing the constant parameter of the IteratedSinZ set.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct IteratedSinZDescriptor {
pub c: Complex,
}
/// Describes parameters specific to a Mandelbrot fractal.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MandelbrotDescriptor {}
/// Describes parameters specific to a BurningShip fractal.
///
/// Attributes:
/// - `c`: A `Complex` number representing the constant parameter of the BurningShip set.
/// - `divergence_threshold_square`: The square of the divergence threshold. Points whose magnitude square exceeds this threshold are considered to diverge.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BurningShipDescriptor {
pub c: Complex,
pub divergence_threshold_square: f64,
}
/// Describes parameters specific to a Newton-Raphson z3 fractal.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct NewtonRaphsonZ3Descriptor {}
/// Describes parameters specific to a Newton-Raphson z3 fractal.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct NewtonRaphsonZ4Descriptor {}