Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.81 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.         long number=0;                 /*number to find*/
  23.         int counter=0;                  /*multiplier for seek depth*/
  24.     double x,xx,y,cx,cy;
  25.     int iteration,hx,hy;
  26.     int itermax = 100;      /* how many iterations to do    */
  27.     double magnify=1.0;     /* no magnification     */
  28.     int hxres = 500;        /* horizonal resolution     */
  29.     int hyres = 500;        /* vertical resolution      */
  30.  
  31.  
  32.         number=atoi(argv[1]);
  33.  
  34.  
  35.  
  36.  
  37.  
  38.     /* header for PPM output */
  39.     /*printf("P6\n# CREATOR: Eric R Weeks / mandel program\n");*/
  40.     /*printf("%d %d\n255\n",hxres,hyres);*/
  41.  
  42.     for (hy=1;hy<=hyres;hy++)  {
  43.         for (hx=1;hx<=hxres;hx++)  {
  44.             cx = (((float)hx)/((float)hxres)-0.5)/magnify*3.0-0.7;
  45.             cy = (((float)hy)/((float)hyres)-0.5)/magnify*3.0;
  46.             x = 0.0; y = 0.0;
  47.             for (iteration=1;iteration<itermax;iteration++)  {
  48.                 xx = x*x-y*y+cx;
  49.                 y = 2.0*x*y+cy;
  50.                 x = xx;
  51.                                 number = xx * 1000000000;
  52.                                 if (number-input_number==0)
  53.                                   printf("number %d\niteration:%d\nx:%d\n,y:%d\n",number,iteration,x,y);
  54.                 if (x*x+y*y>100.0)  iteration = 999999;
  55.             }
  56.     /*      if (iteration<99999)  color(0,255,255);
  57.             else color(180,0,0); */
  58.         }
  59.     }
  60. }
  61.  
  62. void color(int red, int green, int blue)  {
  63.     fputc((char)red,stdout);
  64.     fputc((char)green,stdout);
  65.     fputc((char)blue,stdout);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement