Exemplo n.º 1
0
int* synth_mandel(int width, int height, float minx, float maxx, float miny, float maxy) {
	int* bitmap = (int*)malloc(sizeof(int) * width * height);
	int i, j;
	for (i=0; i<height; i++) {
		float y = ((i * 1.0) / height) * (maxy - miny) + miny;
		float y2 = maxy + miny - y;
		for (j=0; j<width; j++) {
			float x = ((j * 1.0) / width) * (maxx - minx) + minx;
			float x2 = maxx + maxy - x;
			float v = lyapunov(x, y, 1000, "AABABBBABB");
//			float q = lyapunov(x, y, 1000, "AABABAABAA");
			float t = - lyapunov(x, y, 1000, "BABABBBA");
			bitmap[i * width + j] = synth_color(v, 65536) | synth_color(t, 1);
		}
		printf(".");
		fflush(stdout);
	}
	printf("\n");
	return bitmap;
}
Exemplo n.º 2
0
static void search(three_d_struct *three_d, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = three_d -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_a = three_d -> a;
	double temp_b = three_d -> b;
	double temp_c = three_d -> c;
	double temp_d = three_d -> d;
	double temp_e = three_d -> e;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], three_d -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		three_d -> a = (drand48() * (three_d -> a_hi - three_d -> a_lo)) + three_d -> a_lo;
		three_d -> b = (drand48() * (three_d -> b_hi - three_d -> b_lo)) + three_d -> b_lo;
		three_d -> c = (drand48() * (three_d -> c_hi - three_d -> c_lo)) + three_d -> c_lo;
		three_d -> d = (drand48() * (three_d -> d_hi - three_d -> d_lo)) + three_d -> d_lo;
		three_d -> e = (drand48() * (three_d -> e_hi - three_d -> e_lo)) + three_d -> e_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(three_d, NULL, argc, vars);
		do { calc(three_d, three_d -> vars); } while(jump--);
		three_d -> lyap_exp = lyapunov((void *) three_d, (t_gotfn) calc, M_var_count, (double *) three_d -> vars);
		if (isnan(three_d -> lyap_exp)) { not_found = 1; }
		if (three_d -> lyap_exp < three_d -> lyap_lo || three_d -> lyap_exp > three_d -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(three_d, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) three_d -> lyap_limit);
		post("Try using wider constraints.");
		three_d -> a = temp_a;
		three_d -> b = temp_b;
		three_d -> c = temp_c;
		three_d -> d = temp_d;
		three_d -> e = temp_e;
		outlet_anything(three_d -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		three_d -> failure_ratio = (three_d -> lyap_limit - not_expired) / three_d -> lyap_limit;
		make_results(three_d);
		outlet_anything(three_d -> search_outlet, gensym("search"), M_search_count, three_d -> search_out);
	}
}
Exemplo n.º 3
0
static void search(rossler_struct *rossler, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = rossler -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_h = rossler -> h;
	double temp_a = rossler -> a;
	double temp_b = rossler -> b;
	double temp_c = rossler -> c;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], rossler -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		rossler -> h = (drand48() * (rossler -> h_hi - rossler -> h_lo)) + rossler -> h_lo;
		rossler -> a = (drand48() * (rossler -> a_hi - rossler -> a_lo)) + rossler -> a_lo;
		rossler -> b = (drand48() * (rossler -> b_hi - rossler -> b_lo)) + rossler -> b_lo;
		rossler -> c = (drand48() * (rossler -> c_hi - rossler -> c_lo)) + rossler -> c_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(rossler, NULL, argc, vars);
		do { calc(rossler, rossler -> vars); } while(jump--);
		rossler -> lyap_exp = lyapunov((void *) rossler, (t_gotfn) calc, M_var_count, (double *) rossler -> vars);
		if (isnan(rossler -> lyap_exp)) { not_found = 1; }
		if (rossler -> lyap_exp < rossler -> lyap_lo || rossler -> lyap_exp > rossler -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(rossler, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) rossler -> lyap_limit);
		post("Try using wider constraints.");
		rossler -> h = temp_h;
		rossler -> a = temp_a;
		rossler -> b = temp_b;
		rossler -> c = temp_c;
		outlet_anything(rossler -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		rossler -> failure_ratio = (rossler -> lyap_limit - not_expired) / rossler -> lyap_limit;
		make_results(rossler);
		outlet_anything(rossler -> search_outlet, gensym("search"), M_search_count, rossler -> search_out);
	}
}
Exemplo n.º 4
0
static void search(mlogistic_struct *mlogistic, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = mlogistic -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_c = mlogistic -> c;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], mlogistic -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		mlogistic -> c = (drand48() * (mlogistic -> c_hi - mlogistic -> c_lo)) + mlogistic -> c_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(mlogistic, NULL, argc, vars);
		do { calc(mlogistic, mlogistic -> vars); } while(jump--);
		mlogistic -> lyap_exp = lyapunov((void *) mlogistic, (t_gotfn) calc, M_var_count, (double *) mlogistic -> vars);
		if (isnan(mlogistic -> lyap_exp)) { not_found = 1; }
		if (mlogistic -> lyap_exp < mlogistic -> lyap_lo || mlogistic -> lyap_exp > mlogistic -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(mlogistic, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) mlogistic -> lyap_limit);
		post("Try using wider constraints.");
		mlogistic -> c = temp_c;
		outlet_anything(mlogistic -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		mlogistic -> failure_ratio = (mlogistic -> lyap_limit - not_expired) / mlogistic -> lyap_limit;
		make_results(mlogistic);
		outlet_anything(mlogistic -> search_outlet, gensym("search"), M_search_count, mlogistic -> search_out);
	}
}
Exemplo n.º 5
0
static void search(strange1_struct *strange1, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = strange1 -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_a0 = strange1 -> a0;
	double temp_a1 = strange1 -> a1;
	double temp_a2 = strange1 -> a2;
	double temp_a3 = strange1 -> a3;
	double temp_a4 = strange1 -> a4;
	double temp_a5 = strange1 -> a5;
	double temp_b0 = strange1 -> b0;
	double temp_b1 = strange1 -> b1;
	double temp_b2 = strange1 -> b2;
	double temp_b3 = strange1 -> b3;
	double temp_b4 = strange1 -> b4;
	double temp_b5 = strange1 -> b5;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], strange1 -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		strange1 -> a0 = (drand48() * (strange1 -> a0_hi - strange1 -> a0_lo)) + strange1 -> a0_lo;
		strange1 -> a1 = (drand48() * (strange1 -> a1_hi - strange1 -> a1_lo)) + strange1 -> a1_lo;
		strange1 -> a2 = (drand48() * (strange1 -> a2_hi - strange1 -> a2_lo)) + strange1 -> a2_lo;
		strange1 -> a3 = (drand48() * (strange1 -> a3_hi - strange1 -> a3_lo)) + strange1 -> a3_lo;
		strange1 -> a4 = (drand48() * (strange1 -> a4_hi - strange1 -> a4_lo)) + strange1 -> a4_lo;
		strange1 -> a5 = (drand48() * (strange1 -> a5_hi - strange1 -> a5_lo)) + strange1 -> a5_lo;
		strange1 -> b0 = (drand48() * (strange1 -> b0_hi - strange1 -> b0_lo)) + strange1 -> b0_lo;
		strange1 -> b1 = (drand48() * (strange1 -> b1_hi - strange1 -> b1_lo)) + strange1 -> b1_lo;
		strange1 -> b2 = (drand48() * (strange1 -> b2_hi - strange1 -> b2_lo)) + strange1 -> b2_lo;
		strange1 -> b3 = (drand48() * (strange1 -> b3_hi - strange1 -> b3_lo)) + strange1 -> b3_lo;
		strange1 -> b4 = (drand48() * (strange1 -> b4_hi - strange1 -> b4_lo)) + strange1 -> b4_lo;
		strange1 -> b5 = (drand48() * (strange1 -> b5_hi - strange1 -> b5_lo)) + strange1 -> b5_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(strange1, NULL, argc, vars);
		do { calc(strange1, strange1 -> vars); } while(jump--);
		strange1 -> lyap_exp = lyapunov((void *) strange1, (t_gotfn) calc, M_var_count, (double *) strange1 -> vars);
		if (isnan(strange1 -> lyap_exp)) { not_found = 1; }
		if (strange1 -> lyap_exp < strange1 -> lyap_lo || strange1 -> lyap_exp > strange1 -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(strange1, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) strange1 -> lyap_limit);
		post("Try using wider constraints.");
		strange1 -> a0 = temp_a0;
		strange1 -> a1 = temp_a1;
		strange1 -> a2 = temp_a2;
		strange1 -> a3 = temp_a3;
		strange1 -> a4 = temp_a4;
		strange1 -> a5 = temp_a5;
		strange1 -> b0 = temp_b0;
		strange1 -> b1 = temp_b1;
		strange1 -> b2 = temp_b2;
		strange1 -> b3 = temp_b3;
		strange1 -> b4 = temp_b4;
		strange1 -> b5 = temp_b5;
		outlet_anything(strange1 -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		strange1 -> failure_ratio = (strange1 -> lyap_limit - not_expired) / strange1 -> lyap_limit;
		make_results(strange1);
		outlet_anything(strange1 -> search_outlet, gensym("search"), M_search_count, strange1 -> search_out);
	}
}