| Crates.io | strange-attractors |
| lib.rs | strange-attractors |
| version | 0.1.3 |
| created_at | 2025-12-31 17:12:55.721829+00 |
| updated_at | 2025-12-31 17:20:33.760556+00 |
| description | Study into strange attractor visualization in a TUI. |
| homepage | https://gitlab.com/ngreese/strange-attractors |
| repository | |
| max_upload_size | |
| id | 2015022 |
| size | 884,639 |
This repository's purpose is to perform a small study in modeling strange attractors using Rust.
It is a simple binary that draws a series of points in a TUI interface using the ratatui and crossterm crates.
It is by no means good Rust code, if you want to see that look at my other crates dingus. This is purely an experiment fueled by a spark of passion at 3 AM one night.
The formulae used are shown below. They are also documented in the respective structs doc comments.
$$ \begin{aligned} x_{n+1} &= 1 - a x_n^2 + y_n \\ y_{n+1} &= b x_n \end{aligned} $$
$$ \begin{aligned} \frac{dx}{dt} &= \sigma (y - x) \ \frac{dy}{dt} &= x (\rho - z) - y \ \frac{dz}{dt} &= x y - \beta z \end{aligned} $$
Using a discrete time step $\Delta t$, the next point $(x_{n+1}, y_{n+1}, z_{n+1})$ is computed via Euler integration:
$$ \begin{aligned} x_{n+1} &= x_n + \sigma (y_n - x_n), \Delta t \ y_{n+1} &= y_n + (x_n (\rho - z_n) - y_n), \Delta t \ z_{n+1} &= z_n + (x_n y_n - \beta z_n), \Delta t \end{aligned} $$
Where:
The project is split up into two primary modules:
formulae - Contains structs and functions used to calculate the points of the attractors.tui - Contains the code used to perform the visualization of the attractors.This project is a WIP and below tracks what features/attractors are implemented.
The program can be run using ./stranger <ARGS> with the binary or cargo run -- <ARGS> within the repository. The arguments are as follows:
<ATTRACTOR TYPE> - The first argument of the binary is the attractor type. They are as follows:
henon - Visualize a Henon map.lorenz - Visualize a Lorenz attractor.--h, --help - Prints the usage information.--p, --parameters <A>,<B>,<C> - Sets the parameters of the respective attractor.--debug - Does not open a TUI window, prints 1000 iterations of the attractor to stdout. Used for debugging.The program utilizes user input for various controls:
q - Quit the program.+/- - Increase/decrease the time step.1,2,3 - Select the axis to visualize. (Note: Only used for Lorenz attractor)Spacebar - Toggle point color.Fun part! Screenshots
The colors of the points when toggled visualize the X, Y, and Z components as R, G, and B respectively.



