Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include "gnuplot_i.h"
  5. #define BOUND 9
  6. #define NMAX 300
  7. #define NUM_ROW_COL 500
  8.  
  9. int mandelmann(double x, double y, double cx, double cy, int n) {
  10.     double zx, zy;
  11.     if(n<NMAX && (x*x+y*y)<BOUND){
  12.         zx=(x*x-y*y+cx);
  13.         zy=(2*x*y+cy);
  14.         if(zx==x && zy==y) return NMAX;
  15.         n=mandelmann(zx,zy,cx,cy,n+1);
  16.     }
  17.     return n;
  18. }
  19.  
  20. int main()
  21. {
  22.     gnuplot_ctrl *h1=NULL;
  23.     h1 = gnuplot_init() ;
  24.     gnuplot_cmd(h1,"set view map");
  25.  
  26.     int i,j=0,N=1000,n=2;
  27.     char q;
  28.     double xmin=-2, xmax=1.0, ymin=-1, ymax=1,x,y;
  29.  
  30.     FILE* outfile=NULL;
  31.  
  32.     gnuplot_ctrl *h=NULL;
  33.     h=gnuplot_init();
  34.     gnuplot_cmd(h,"set view map");
  35.  
  36.     do{
  37.         printf("\nBitte waehlen Sie eine Menue-Option:\n");
  38.         printf("\n 1) Bildbereich setzen");
  39.         printf("\n 2) Datei erzeugen");
  40.         printf("\n 3) Bild zeichnen");
  41.         printf("\n 4) ENDE\n vvvbnm");
  42.         q = 0;
  43.         while (q < '1' || q > '4') {
  44.         scanf("%c",&q);
  45.         }
  46.  
  47.         switch(q){
  48.  
  49.     case '1':
  50.         printf("\nxmin = ");
  51.         scanf("%lf",&xmin);
  52.         printf("\nxmax = ");
  53.         scanf("%lf",&xmax);
  54.         printf("\nymin = ");
  55.         scanf("%lf",&ymin);
  56.         printf("\nymax = ");
  57.         scanf("%lf",&ymax);
  58.         break;
  59.  
  60.     case '2':
  61.         outfile=fopen("mb.txt","w");
  62.           for(i=0;i<=NUM_ROW_COL;i++)
  63.                 {
  64.                     for(j=0;j<=NUM_ROW_COL;j++)
  65.                     {
  66.                         x = xmin + i*((xmax - xmin)/NUM_ROW_COL);
  67.                         y = ymin + j*((ymax - ymin)/NUM_ROW_COL);
  68.                         n = mandelmann(0,0,x,y,0);
  69.                         fprintf(outfile, "%lf %lf %d\n",x,y,n);
  70.                     }
  71.                     fprintf(outfile, "\n");
  72.                 }
  73.         break;
  74.  
  75.     case '3':
  76.           for(i=0;i<=N;i++)
  77.                 {
  78.  
  79.                 }
  80.         gnuplot_resetplot(h);
  81.         gnuplot_cmd(h,"splot \"mb.txt\" w pm3d");
  82.         break;
  83.  
  84.     case '4':
  85.         break;
  86.      }
  87.  
  88.     }while(q!='4');
  89.  
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement