Expand description
§2D Endomorphisms
Mathematical transformations that map points from the unit square to itself. These functions are commonly used in fractal systems, particularly Iterated Function Systems (IFS), and provide various artistic and mathematical effects for generative art applications.
§What are Endomorphisms?
An endomorphism is a mathematical function that maps a space to itself.
In this context, all functions map points within or around the unit square
[-1, 1] × [-1, 1] to new positions, creating various visual effects.
§Available Transformations
§Trigonometric Functions
sinusoid(): Applies sine function to both coordinateshankerchief(): Creates handkerchief-like distortionsheart(): Creates heart-shaped transformations
§Geometric Transformations
spherical(): Spherical inversion transformationswirl(): Creates swirling, spiral effectshorseshoe(): Horseshoe-shaped transformationdisc(): Disc-based coordinate transformation
§Coordinate System Changes
to_polar(): Converts to polar coordinate representation
§Usage in Fractal Systems
use wassily_algorithms::*;
use wassily_core::*;
// Create an IFS (Iterated Function System)
let mut point = pt(0.5, 0.3);
let mut canvas = Canvas::new(800, 600);
// Apply transformations iteratively
for _ in 0..10000 {
// Randomly choose a transformation
point = match rand::random::<u8>() % 3 {
0 => swirl(point),
1 => heart(point),
_ => spherical(point),
};
// Plot the transformed point
let screen_x = (point.x + 1.0) * 400.0;
let screen_y = (point.y + 1.0) * 300.0;
canvas.dot(screen_x, screen_y, *WHITE);
}§Mathematical Properties
Each transformation has unique mathematical properties:
- Continuous: All transformations are continuous functions
- Bounded: Most transformations keep points within reasonable bounds
- Differentiable: Most functions are smooth and differentiable
- Invertible: Some transformations are invertible, others are not
§Applications
- Fractal Generation: IFS fractals and strange attractors
- Artistic Effects: Distortion effects for images and shapes
- Mathematical Visualization: Studying function behavior
- Animation: Creating organic, flowing motion patterns