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 */
- double number=0; /*number to *extract*/
- int intnumber=0;
- 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 */
- input_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 = x;
- /* normalise to 0.xxxx...*/
- number=(x<0)?number=(number+abs(x))*-1:number-abs(x);
- intnumber=(int) (number*1000000);
- printf("%d\n%f\n%f",iteration,x,y);
- if (x*x+y*y>100.0) iteration = 999999;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement