Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- @physics.emory.edu
- ** http://www.physics.emory.edu/~weeks/
- **
- ** This program is public domain, but this header must be left intact
- ** and unchanged.
- **
- ** to compile: cc -o mand mandel.c
- **
- **/
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- void color();
- int main (int argc, char * argv[])
- {
- int scale=0; /*number of digits of precision to seek*/
- long input_number=0; /*number to find */
- long number=0; /*number to find*/
- int counter=0; /*multiplier for seek depth*/
- double x,xx,y,cx,cy;
- int iteration,hx,hy;
- int itermax = 100; /* how many iterations to do */
- double magnify=1.0; /* no magnification */
- int hxres = 500; /* horizonal resolution */
- int hyres = 500; /* vertical resolution */
- number=atoi(argv[1]);
- /* header for PPM output */
- /*printf("P6\n# CREATOR: Eric R Weeks / mandel program\n");*/
- /*printf("%d %d\n255\n",hxres,hyres);*/
- for (hy=1;hy<=hyres;hy++) {
- for (hx=1;hx<=hxres;hx++) {
- cx = (((float)hx)/((float)hxres)-0.5)/magnify*3.0-0.7;
- cy = (((float)hy)/((float)hyres)-0.5)/magnify*3.0;
- x = 0.0; y = 0.0;
- for (iteration=1;iteration<itermax;iteration++) {
- xx = x*x-y*y+cx;
- y = 2.0*x*y+cy;
- x = xx;
- number = xx * 1000000000;
- if (number-input_number==0)
- printf("number %d\niteration:%d\nx:%d\n,y:%d\n",number,iteration,x,y);
- if (x*x+y*y>100.0) iteration = 999999;
- }
- /* if (iteration<99999) color(0,255,255);
- else color(180,0,0); */
- }
- }
- }
- void color(int red, int green, int blue) {
- fputc((char)red,stdout);
- fputc((char)green,stdout);
- fputc((char)blue,stdout);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement