Skip to content

Fractals in c - printed in terminal, rendered as images, live view using SDL

License

Notifications You must be signed in to change notification settings

tucnakomet1/fractal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6582d5 · Jul 31, 2023

History

28 Commits
Jul 31, 2023
Jul 24, 2023
Jul 24, 2023
Jul 30, 2023
Jul 31, 2023

Repository files navigation

Chaos in stb

C library that simulates fractals and attractors (only in stb). You can generate them into terminal as ASCII art or into image (using stb library).

Table of contents

Bifurcation diagram

  • Available in ASCII
  • Available in stb

x n + 1 = x n k ( 1 x n )

stb
bifurcation diagram in stb

Attractors

Lorenz attractor

Lorenz attractor is a strange attractor named after Edward Lorenz who described it in 1963.

For σ = 10 , ρ = 28 , β = 8 3 and x = 0.1 , y = 0 , z = 0 is the system described by the following three equations: $\begin{cases}\frac{dx}{dt} = \sigma (y-x)\\frac{dy}{dt} = x (\rho -z) -y\\frac{dz}{dt} = xy-\beta x\end{cases}$

stb
Lorenz attractor

Thomas attractor

Thomas' cyclically symmetric attractor is a 3D strange attractor named after René Thomas.

For λ = 0.19 and x = 0.1 , y = 0 , z = 0 is the system described by the following three equations: $\begin{cases}\frac {dx}{dt}= \sin(y) - \lambda x\\frac {dy}{dt}= \sin(z) - \lambda y\\frac {dz}{dt}= \sin(x) - \lambda z\end{cases}$

stb
thoma attractor in stb

Rössler attractor

Lorenz attractor is an attractor named after Otto Rössler who described it in 1976.

For α = 0.2 , β = 0.2 , γ = 14 and x = 0.1 , y = 0 , z = 0 is the system described by the following three equations: $\begin{cases}\frac {dx}{dt}=-y-z\\frac {dy}{dt}=x+\alpha y\\frac {dz}{dt}=\beta+z\cdot(x-\gamma)\end{cases}$

stb
Rössler attractor

Chen & Lu Chen attractor

The (Lu) Chen attractor is named after Jinhu Lu and Guanrong Chen.

For Chen attractor α = 40 , β = 3 , γ = 28 and x = 0.1 , y = 0.5 , z = 0.6 is the system described by the following three equations: $\begin{cases}\frac {dx}{dt}=\alpha \cdot (y - x)\\frac {dy}{dt}=(\gamma - \alpha) \cdot x - xz + \gamma y\\frac {dz}{dt}=xy - \beta z\end{cases}$

For Lu Chen attractor α = 34.5 , β = 9 , γ = 20 , ω = 10 and x = 0.1 , y = 0.3 , z = 0.6 is the system described by the following three equations: $\begin{cases}\frac {dx}{dt}=\alpha \cdot (y - x)\\frac {dy}{dt}=x - xz + \gamma y + \omega\\frac {dz}{dt}=xy - \beta z\end{cases}$

Chen Lu Chen
Chen attractor Lu Chen attractor

Rabinovich–Fabrikant attractor

The Rabinovich–Fabrikant equations are a set of three equations named after Mikhail Rabinovich and Anatoly Fabrikant, who described them in 1979.

For α = 1.1 , γ = 0.87 and x = 1 , y = 0 , z = 0.5 is the system described by the following three equations: $\begin{cases}\frac {dx}{dt}=y \cdot (z-1+x^2) + \gamma x\\frac {dy}{dt}=x\cdot (3z+1-x^2) + \gamma y\\frac {dz}{dt}=-2z\cdot (\alpha +xy)\end{cases}$

stb 1 stb 2
Rabin attractor 1. variant Rabin attractor 2. variant

Hénon map

The Hénon map is a strange attractor named after Michel Hénon.

For α = 1.4 , β = 0.3 and x = 0.1 , y = 0.1 is the system described by the following two equations: $\begin{cases}x_{n+1} = 1 - \alpha x_n^2 + y_n \y_{n+1} = \beta x_n\end{cases}$

stb
Hénon map

Fractals

Cantor set

  • In ASCII
  • In stb

A Cantor set is a fractal that is formed by removing the middle thirds of a line. It is named after Georg Cantor, who introduced it in 1883.

We get it by removing the interval ( 1 3 , 2 3 ) of the content from the line [ 0 , 1 ] . The open middle third of each of these remaining segments is deleted, and there are left these four segments: [ 0 , 1 9 ] [ 2 9 , 1 3 ] [ 2 3 , 7 9 ] [ 8 9 , 1 ] .

The length of the Cantor line converges to 0 .

1 3 + 2 9 + 4 27 + 8 81 + . . . = n = 0 2 n 3 n + 1 = 1 3 n = 0 2 n 3 n = 1 3 ( 1 1 2 3 ) = 1

The Cantor set gas a fractal dimension equal to $\frac{ln(2)}{ln(3)} \approx 0.6309...$.

ASCII stb
cantor setin ASCII cantor set in stb

Sierpiński carpet

  • Available in ASCII
  • Available in stb

A Sierpiński carpet is a fractal formed by recursively removing squares from a surface. It is named after Wacław Sierpiński, who described it in 1916 and it's a generalization of Cantor's set into two dimensions.

The area of a Sierpiński carpet converges to 0 .

S = 1 n = 0 8 n 9 n + 1 a 1 = 1 9 , q = 8 9 S = 1 s = 1 1 9 1 8 9 = 1 1 = 0

The Sierpiński carpet has a fractal dimension equal to l o g ( 8 ) l o g ( 3 ) 1.8928 . . . .

ASCII stb
sierpinski carpet in ASCII sierpinski carpet in stb

Sierpiński triangle

  • Available in ASCII
  • Available in stb

Mandelbrot set

  • Available in ASCII
  • Available in stb
  • Available in SDL
ASCII stb SDL
mandelbrot in ASCII mandelbrot in stb mandelbrot in sdl

Koch snowflake

  • Available in ASCII
  • Available in stb

Barnsley fern

  • Available in ASCII
  • Available in stb

About

Fractals in c - printed in terminal, rendered as images, live view using SDL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published