Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 KB | None | 0 0
  1. /*
  2. @physics.emory.edu
  3.  **  http://www.physics.emory.edu/~weeks/
  4.  **  
  5.  **  This program is public domain, but this header must be left intact
  6.  **  and unchanged.
  7.  **  
  8.  **  to compile:  cc -o mand mandel.c
  9.  **
  10.  **/
  11.  
  12. #include <stdio.h>
  13. #include <math.h>
  14. #include <stdlib.h>
  15. void color();
  16.  
  17. int main (int argc, char * argv[])
  18. {
  19.         int scale=0;               /*number of digits of precision to seek*/      
  20.  
  21.         long input_number=0;      /*number to find */
  22.         double number=0;                 /*number to *extract*/
  23.         int intnumber=0;
  24.         int counter=0;                  /*multiplier for seek depth*/
  25.     double x,xx,y,cx,cy;
  26.     int iteration,hx,hy;
  27.     int itermax = 100;      /* how many iterations to do    */
  28.     double magnify=1.0;     /* no magnification     */
  29.     int hxres = 500;        /* horizonal resolution     */
  30.     int hyres = 500;        /* vertical resolution      */
  31.  
  32.  
  33.         input_number=atoi(argv[1]);
  34.  
  35.  
  36.  
  37.  
  38.  
  39.     /* header for PPM output */
  40.     /*printf("P6\n# CREATOR: Eric R Weeks / mandel program\n");*/
  41.     /*printf("%d %d\n255\n",hxres,hyres);*/
  42.  
  43.     for (hy=1;hy<=hyres;hy++)  {
  44.         for (hx=1;hx<=hxres;hx++)  {
  45.             cx = (((float)hx)/((float)hxres)-0.5)/magnify*3.0-0.7;
  46.             cy = (((float)hy)/((float)hyres)-0.5)/magnify*3.0;
  47.             x = 0.0; y = 0.0;
  48.             for (iteration=1;iteration<itermax;iteration++)  {
  49.                 xx = x*x-y*y+cx;
  50.                 y = 2.0*x*y+cy;
  51.                 x = xx;
  52.  
  53.                                 number = x;
  54.  /* normalise to 0.xxxx...*/
  55.                                 number=(x<0)?number=(number+abs(x))*-1:number-abs(x);
  56.                                 intnumber=(int) (number*1000000);
  57.                                
  58.                                 printf("%d\n%f\n%f",iteration,x,y);
  59.                 if (x*x+y*y>100.0)  iteration = 999999;
  60.      }
  61.    }
  62.   }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement