In this Final Course Project for PRG255, you will develop your own fractal pattern generation code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this Final Course Project for PRG255, you will develop your own fractal pattern generation code using the Mandelbrot and Julia sets. For further background information and details, please make sure to watch this supplemental video recording as well as the recording of our Lab 7 session. Details already discussed in the pre- recorded video have been omitted from this document for conciseness. Your C program will generate one Mandelbrot and one Julia fractal pattern. Both will be written to disk in the Portable Gray Map (PGM) image format. Mandelbrot fractals are generated using an iterative complex function of the following form: Zn+1 = Z² + C Zo = 0, where Z and C are complex numbers. These complex numbers can be thought of as points on a two-dimensional complex plane of size 2x2. The real and imaginary parts of these complex numbers represent the x and y coordinates of points on the complex plane. If our intended output image is projected onto the 2×2 complex plane, then point C represents an individual pixel on the image. As a result, for each individual pixel on the image, we can calculate successive values for Z based on the previous equations. We can also keep track of the length of Z as it gets updated at each iteration, and stop the iterative process when the square of the length of Z exceeds 4.0. The number of iterations required to breach this condition will then determine the color value associated with the pixel represented by the complex number C. The following pseudocode implements the steps required for generating a color value for each individual pixel on the intended output image of your program. This pseudocode implements the same logic described above. step_height 4.0/(double) height step_width 4.0/(double)width maxIter = 400 for (j = 0; j < height; j++) begin for (k = 0; k < width; k++) begin z = 0 + 01 c = (((double)j step_height) 2.0) + (((double)k step_width) 2.0)i color= fractal (z, c, maxIter) maxIter - color image[j][k] fprintf(image[j][k]) end fprintf(endline) end The two-level nested loop shown above iterates through every single pixel on the intended output image as it projects onto a 2x2 complex plane. For each pixel, it sets the value of complex number Z to zero and determines the corresponding complex number C by a simple projection of the image dimensions onto the complex plane. The color of this pixel is calculated by the fractal (z, c, maxIter) function. Note that the fractal(z, c, maxIter) function implements the same logic we used as part of Lab Modules 8 and 9. Once the color is determined, it is inverted by subtracting it from maxIter, which represents the color white in the PGM image. This value is now written to the output file as the color of the pixel represented by complex number C. The logic for generating the Julia fractal pattern is very similar to the one outlined above. The subtle difference is that the complex number C is set equal to a constant and remains unchanged. The complex number Z is used instead to iterate over all individual pixels of the image in the same way that C iterates over the image pixels in the Mandelbrot set. The constant value of C used will be equal to -0.8 +0.1561. Project Requirements Your implementation of the fractal pattern generation code must meet all the following requirements for full credit. 1. You must implement your code in a single C file named "main.c". 2. Your program must #include only the and libraries in your "main.c" program. 3. You must define and implement a typdef struct called Complex with two double members: real and imag. Your program must use this data type to store all complex numbers. 4. You must implement a function for carrying out any complex multiplication using the following interface: Complex complex_mult (Complex* a, Complex* b) 5. You must implement a function for carrying out any complex addition using the following interface: Complex complex_add(Complex* a, Complex* b) 6. You must implement a function for calculating the square value of the length of a complex number using the following interface: double len_square (Complex* a) 7. You must implement a function for calculating the color value of a given pixel using the same logic outlined in the Lab Modules 8 and 9. The function must have the following interface: int fractal (Complex* z, Complex* c, int maxIter) 8. Your program must output two separate images. One is to be named "mandelbrot.pgm", and the other "julia.pgm", displaying the Mandelbrot and Julia fractal patterns, respectively. 9. Your program must prompt the user to provide the width and height of the output images. The same width and height pair may be used for both output images. 10. You must use dynamic memory allocation to allocate a two-dimensional integer array called image based on the width and height for the purpose of storing the individual color values of all pixels in the images. This allocated array must be released prior to the end of your program. In this Final Course Project for PRG255, you will develop your own fractal pattern generation code using the Mandelbrot and Julia sets. For further background information and details, please make sure to watch this supplemental video recording as well as the recording of our Lab 7 session. Details already discussed in the pre- recorded video have been omitted from this document for conciseness. Your C program will generate one Mandelbrot and one Julia fractal pattern. Both will be written to disk in the Portable Gray Map (PGM) image format. Mandelbrot fractals are generated using an iterative complex function of the following form: Zn+1 = Z² + C Zo = 0, where Z and C are complex numbers. These complex numbers can be thought of as points on a two-dimensional complex plane of size 2x2. The real and imaginary parts of these complex numbers represent the x and y coordinates of points on the complex plane. If our intended output image is projected onto the 2×2 complex plane, then point C represents an individual pixel on the image. As a result, for each individual pixel on the image, we can calculate successive values for Z based on the previous equations. We can also keep track of the length of Z as it gets updated at each iteration, and stop the iterative process when the square of the length of Z exceeds 4.0. The number of iterations required to breach this condition will then determine the color value associated with the pixel represented by the complex number C. The following pseudocode implements the steps required for generating a color value for each individual pixel on the intended output image of your program. This pseudocode implements the same logic described above. step_height 4.0/(double) height step_width 4.0/(double)width maxIter = 400 for (j = 0; j < height; j++) begin for (k = 0; k < width; k++) begin z = 0 + 01 c = (((double)j step_height) 2.0) + (((double)k step_width) 2.0)i color= fractal (z, c, maxIter) maxIter - color image[j][k] fprintf(image[j][k]) end fprintf(endline) end The two-level nested loop shown above iterates through every single pixel on the intended output image as it projects onto a 2x2 complex plane. For each pixel, it sets the value of complex number Z to zero and determines the corresponding complex number C by a simple projection of the image dimensions onto the complex plane. The color of this pixel is calculated by the fractal (z, c, maxIter) function. Note that the fractal(z, c, maxIter) function implements the same logic we used as part of Lab Modules 8 and 9. Once the color is determined, it is inverted by subtracting it from maxIter, which represents the color white in the PGM image. This value is now written to the output file as the color of the pixel represented by complex number C. The logic for generating the Julia fractal pattern is very similar to the one outlined above. The subtle difference is that the complex number C is set equal to a constant and remains unchanged. The complex number Z is used instead to iterate over all individual pixels of the image in the same way that C iterates over the image pixels in the Mandelbrot set. The constant value of C used will be equal to -0.8 +0.1561. Project Requirements Your implementation of the fractal pattern generation code must meet all the following requirements for full credit. 1. You must implement your code in a single C file named "main.c". 2. Your program must #include only the and libraries in your "main.c" program. 3. You must define and implement a typdef struct called Complex with two double members: real and imag. Your program must use this data type to store all complex numbers. 4. You must implement a function for carrying out any complex multiplication using the following interface: Complex complex_mult (Complex* a, Complex* b) 5. You must implement a function for carrying out any complex addition using the following interface: Complex complex_add(Complex* a, Complex* b) 6. You must implement a function for calculating the square value of the length of a complex number using the following interface: double len_square (Complex* a) 7. You must implement a function for calculating the color value of a given pixel using the same logic outlined in the Lab Modules 8 and 9. The function must have the following interface: int fractal (Complex* z, Complex* c, int maxIter) 8. Your program must output two separate images. One is to be named "mandelbrot.pgm", and the other "julia.pgm", displaying the Mandelbrot and Julia fractal patterns, respectively. 9. Your program must prompt the user to provide the width and height of the output images. The same width and height pair may be used for both output images. 10. You must use dynamic memory allocation to allocate a two-dimensional integer array called image based on the width and height for the purpose of storing the individual color values of all pixels in the images. This allocated array must be released prior to the end of your program.
Expert Answer:
Answer rating: 100% (QA)
the color map isnt exactly perfect check if your instructor specifies any specifice kind of color ma... View the full answer
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Please make sure to display your thought process? It is imperative to be able to follow how the answer was deduced. Please be as thorough as possible. Please address all parts of this question as...
-
Two points in a plane have polar coordinates (2.50 m, 30.0) and (3.80 m, 120.0). Determine (a) the Cartesian coordinates of these points and (b) the distance between them.
-
Map the upper half z-plane onto the unit disk |w| < 1 so that 0, , 1 are mapped onto 1, i, i, respectively. What are the boundary conditions on |w| = 1 resulting from the potential in Prob. 9? What...
-
If a restaurant's total sales on a given day were $4,350.00, and the restaurant had served 365 customers, what is the average dollar sale? $10.05 $11.92 $11.35 $11.05
-
As a plant manager of a firm, you are trying to decide whether to open a new factory outlet store, which would cost about $500,000. Success of the outlet store depends on demand in the new region. If...
-
Emil Fischer's determination of the structure of glucose was carried out as the nineteenth century ended and the twentieth began. The structure of no other sugar was known at that time, and none of...
-
A silicon substrate \(10 \mathrm{~cm}\) long is exposed to a gas stream containing an arsenic precursor so that a GaAs film can be deposited on the surface. Estimate the mass-transfer coefficient,...
-
Kemp leased a gas filling station from Baehr. Kemp, who was heavily indebted to Penn-O-Tex Oil Corp., transferred to it his right to receive payments on all claims. When Baehr complained that the...
-
Based upon your in-depth knowledge of Lululemon, you are to identify and describe your firm's most persuasive growth opportunity: Your growth opportunity may fall within 1 of the 3 common situations...
-
Nowhereland is an island economy with population of 4 Alice, Bob, Catherine and David. Everyday there are two survival activities under the northerly Sea of Ferocity: catching jellyfish and...
-
The month of July, the client had a database outage, lose some data, what are there any issues that you would want to bring to the audit manager's attention? What assertions will be?
-
Under what conditions, if any, can your audit team do the six inventory test counts at the Urbana, IL warehouse and leave the 16 test counts at NM & PA to Starblocks' internal auditors? Justify your...
-
What might be a potential pitfall of preparing and maintaining a rolling budget? Explain.
-
On November 1, 2020, ABC Products forecasts that it will purchase 1,000,000 bushels of oats in 4 months for use in the manufacture of its cereal products. To hedge against rising costs, ABC Products...
-
Consider the following two mutually exclusive projects: Cash Flow Cash Flow Year (X) M 0 -$20,300 20,300 1 8,925 10,250 23 9,250 7,875 3 8.875 8,775 Calculate the IRR for each project. (Do not round...
-
Which three activities are part of the function of accounting? Multiple select question. recording financial transactions classifying financial transactions interpreting financial transactions...
-
Below is a sample of the data in the file NFLAttendance which contains the 32 teams in the National Football League, their conference affiliation, their division, and their average home attendance....
-
Where I live, most people do not have swimming pools despite the fact that it gets very hot in the summers. Thus, families, especially those with children, try to find swimming pools in the area. Our...
-
The following is intended to explore what kinds of own-price demand relationships are logically possible in a two-good model with exogenous income (unless otherwise specified). A: For each of the...
-
Consider a teenager who evaluates whether she should engage in sexual activity with her partner of the opposite sex. She thinks ahead and expects to have a present discounted level of life-time...
-
Who was Phar-Mors flamboyant Chief Executive Officer?
-
Which of the following generally is not considered something of value? 1. Cash, money or checks 2. Airline miles or hotel credits associated with frequent activity (e.g., frequent flier miles) 3. An...
-
Which of the following is not one of the five major categories of fraudulent disbursements? 1. Payroll schemes 2. Expense reimbursement schemes 3. Shell company schemes 4. Billing schemes
Study smarter with the SolutionInn App