Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include "gnuplot_i.h"
- #define BOUND 9
- #define NMAX 300
- #define NUM_ROW_COL 500
- int mandelmann(double x, double y, double cx, double cy, int n) {
- double zx, zy;
- if(n<NMAX && (x*x+y*y)<BOUND){
- zx=(x*x-y*y+cx);
- zy=(2*x*y+cy);
- if(zx==x && zy==y) return NMAX;
- n=mandelmann(zx,zy,cx,cy,n+1);
- }
- return n;
- }
- int main()
- {
- gnuplot_ctrl *h1=NULL;
- h1 = gnuplot_init() ;
- gnuplot_cmd(h1,"set view map");
- int i,j=0,N=1000,n=2;
- char q;
- double xmin=-2, xmax=1.0, ymin=-1, ymax=1,x,y;
- FILE* outfile=NULL;
- gnuplot_ctrl *h=NULL;
- h=gnuplot_init();
- gnuplot_cmd(h,"set view map");
- do{
- printf("\nBitte waehlen Sie eine Menue-Option:\n");
- printf("\n 1) Bildbereich setzen");
- printf("\n 2) Datei erzeugen");
- printf("\n 3) Bild zeichnen");
- printf("\n 4) ENDE\n vvvbnm");
- q = 0;
- while (q < '1' || q > '4') {
- scanf("%c",&q);
- }
- switch(q){
- case '1':
- printf("\nxmin = ");
- scanf("%lf",&xmin);
- printf("\nxmax = ");
- scanf("%lf",&xmax);
- printf("\nymin = ");
- scanf("%lf",&ymin);
- printf("\nymax = ");
- scanf("%lf",&ymax);
- break;
- case '2':
- outfile=fopen("mb.txt","w");
- for(i=0;i<=NUM_ROW_COL;i++)
- {
- for(j=0;j<=NUM_ROW_COL;j++)
- {
- x = xmin + i*((xmax - xmin)/NUM_ROW_COL);
- y = ymin + j*((ymax - ymin)/NUM_ROW_COL);
- n = mandelmann(0,0,x,y,0);
- fprintf(outfile, "%lf %lf %d\n",x,y,n);
- }
- fprintf(outfile, "\n");
- }
- break;
- case '3':
- for(i=0;i<=N;i++)
- {
- }
- gnuplot_resetplot(h);
- gnuplot_cmd(h,"splot \"mb.txt\" w pm3d");
- break;
- case '4':
- break;
- }
- }while(q!='4');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement