Skip to content

An excuse to get back to Rust and use git without git-fork once for all

License

Notifications You must be signed in to change notification settings

MarioVieilledent/complex_numbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Complex number and Julia Sets display

GitHub top language

A Rust program to implement complex numbers and compute them.

The code is a mess even though it's in Rust and therefore not ready for production.

Screen of program

Complex number calculus

I didn't use any dependence to process complex numbers, it's very easy to implement.

The window and the display of Julia sets is done with Piston engine.

Julia set algorithm

I used the simple Julia Set algorithm, not using float values, but complex numbers which is easier to process operation.

Source: Wikipedia

R = escape radius  # choose R > 0 such that R**2 - R >= sqrt(cx**2 + cy**2)

for each pixel (x, y) on the screen, do:   
{
    zx = scaled x coordinate of pixel # (scale to be between -R and R)
       # zx represents the real part of z.
    zy = scaled y coordinate of pixel # (scale to be between -R and R)
       # zy represents the imaginary part of z.

    iteration = 0
    max_iteration = 1000
  
    while (zx * zx + zy * zy < R**2  AND  iteration < max_iteration) 
    {
        xtemp = zx * zx - zy * zy
        zy = 2 * zx * zy  + cy 
        zx = xtemp + cx
    
        iteration = iteration + 1 
    }
  
    if (iteration == max_iteration)
        return black;
    else
        return iteration;
}

About

An excuse to get back to Rust and use git without git-fork once for all

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages