Coder Social home page Coder Social logo

c3-fractal's Introduction

Hello!

This is lab 1 of the UCLA IEEE C3 program.

Make commands:

Make all
    Compile the project
Make clean
    Delete any compiled executables and temporary files

Once the program is built, run ./fractalgen <filename.png> to generate a fractal

is a multiplier on the size of the fractal. While running fractalgen with 1 should be relatively quick, using a value above 20 will start to take a lot of time. See the Mandelbrot and Fractal class constructors for more information.

Lodepng is a library using to generate .png files. Don't worry about the code in that file. It's abstracted in the save_file method in the Fractal class.

More on m_bitmap...

m_bitmap is a single-dimensional array used to encode the entire image. It's length is equal to the width of the image times the height of the image.

To get the r,g,b values for a coordinate x, y, you might do something like....

m_bitmap[x*m_height*4 + y*4 + 0] // R
m_bitmap[x*m_height*4 + y*4 + 1] // G
m_bitmap[x*m_height*4 + y*4 + 2] // B

To iterate along each pixel, choosing a point in the complex plane for each, you might do something like...

int height = get_height(), width = get_width();
int i, npixels = height*width;
for (i = 0; i<npixels; i++)
{
    int x = i%height;
    int y = i/height;
    
    double c_r = (((double)x)/width)*3.0 - 2.25;
    double c_i = (((double)y)/height)*3.0 - 1.5;

    /// ....

}

Parallelization

We highly recommend using openmp to improve the performance of your application

If you're not sure how to do this, try just adding "#pragma omp parallel for" to the line above your outer for loop

(This will result in the loop being executed out of order and simultaneously on multiple cores. it will jumble any print statements you have)

If this breaks your program, you have some data dependencies you need to resolve.

Continuous Coloring

You may notice that your fractal's coloring has a number of bands of color. In order to get continuous coloring, there's an alternative coloring method mentioned on wikipedia's mandelbrot fractal page.

Resources

I highly suggest the wikipedia page on fractals. In particular, look at the section on computer drawings of the mandelbrot set.

Particular performance improvements will save you a lot of time (parallelism, not testing the main cardioids, etc). So look for these online and on the wikipedia page.

c3-fractal's People

Contributors

mrmuffyman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.