From 0053026871a3def94980593ca56364ee6a7c0f71 Mon Sep 17 00:00:00 2001 From: Erik Reckase Date: Sun, 2 Jan 2011 23:38:13 +0000 Subject: added mobius variation (the one with 8 params, eralex's). git-svn-id: https://flam3.googlecode.com/svn/trunk@151 77852712-ef1d-11de-8684-7d64432d61a3 --- src/flam3.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++- src/flam3.h | 9 ++++++++- src/interpolation.c | 8 ++++++++ src/parser.c | 16 ++++++++++++++++ src/variations.c | 29 ++++++++++++++++++++++++++++ src/variations.h | 1 + 6 files changed, 115 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/flam3.c b/src/flam3.c index fc22856..c56b233 100644 --- a/src/flam3.c +++ b/src/flam3.c @@ -674,6 +674,14 @@ void apply_motion_parameters(flam3_xform *xf, flam3_xform *addto, double blend) APPMOT(auger_freq); APPMOT(auger_scale); APPMOT(flux_spread); + APPMOT(mobius_re_a); + APPMOT(mobius_re_b); + APPMOT(mobius_re_c); + APPMOT(mobius_re_d); + APPMOT(mobius_im_a); + APPMOT(mobius_im_b); + APPMOT(mobius_im_c); + APPMOT(mobius_im_d); for (j = 0; j < flam3_nvariations; j++) APPMOT(var[j]); @@ -974,6 +982,16 @@ void flam3_copy_params(flam3_xform *dest, flam3_xform *src, int varn) { } else if (varn==VAR_FLUX) { /* flux */ dest->flux_spread = src->flux_spread; + } else if (varn==VAR_MOBIUS) { + /* mobius */ + dest->mobius_re_a = src->mobius_re_a; + dest->mobius_re_b = src->mobius_re_b; + dest->mobius_re_c = src->mobius_re_c; + dest->mobius_re_d = src->mobius_re_d; + dest->mobius_im_a = src->mobius_im_a; + dest->mobius_im_b = src->mobius_im_b; + dest->mobius_im_c = src->mobius_im_c; + dest->mobius_im_d = src->mobius_im_d; } } @@ -1813,7 +1831,8 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub int modulus_var=0,oscope_var=0,popcorn2_var=0,separation_var=0; int split_var=0,splits_var=0,stripes_var=0,wedge_var=0,wedgeJ_var=0; int wedgeS_var=0,whorl_var=0,waves2_var=0,auger_var=0,flux_var=0; - + int mobius_var=0; + int j; int lnv; @@ -1929,6 +1948,8 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub auger_var=1; else if (j==VAR_FLUX) flux_var=1; + else if (j==VAR_MOBIUS) + mobius_var=1; } } @@ -2147,6 +2168,17 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub if (flux_var==1) fprintf(f, "flux_spread=\"%g\" ", x->flux_spread); + if (mobius_var==1) { + fprintf(f, "mobius_re_a=\"%g\" ", x->mobius_re_a); + fprintf(f, "mobius_im_a=\"%g\" ", x->mobius_im_a); + fprintf(f, "mobius_re_b=\"%g\" ", x->mobius_re_b); + fprintf(f, "mobius_im_b=\"%g\" ", x->mobius_im_b); + fprintf(f, "mobius_re_c=\"%g\" ", x->mobius_re_c); + fprintf(f, "mobius_im_c=\"%g\" ", x->mobius_im_c); + fprintf(f, "mobius_re_d=\"%g\" ", x->mobius_re_d); + fprintf(f, "mobius_im_d=\"%g\" ", x->mobius_im_d); + } + fprintf(f, "coefs=\""); for (j = 0; j < 3; j++) { if (j) fprintf(f, " "); @@ -2304,6 +2336,15 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub PRINTNON(auger_scale); PRINTNON(flux_spread); + + PRINTNON(mobius_re_a); + PRINTNON(mobius_im_a); + PRINTNON(mobius_re_b); + PRINTNON(mobius_im_b); + PRINTNON(mobius_re_c); + PRINTNON(mobius_im_c); + PRINTNON(mobius_re_d); + PRINTNON(mobius_im_d); if (!zero_matrix(x->c)) { fprintf(f, "coefs=\""); @@ -3374,6 +3415,17 @@ void flam3_random(flam3_genome *cp, int *ivars, int ivars_n, int sym, int spec_x cp->xform[i].flux_spread = 0.5 + flam3_random01()/2.0; } + if (cp->xform[i].var[VAR_MOBIUS] > 0) { + /* Create random params for mobius */ + cp->xform[i].mobius_re_a = flam3_random11(); + cp->xform[i].mobius_im_a = flam3_random11(); + cp->xform[i].mobius_re_b = flam3_random11(); + cp->xform[i].mobius_im_b = flam3_random11(); + cp->xform[i].mobius_re_c = flam3_random11(); + cp->xform[i].mobius_im_c = flam3_random11(); + cp->xform[i].mobius_re_d = flam3_random11(); + cp->xform[i].mobius_im_d = flam3_random11(); + } } diff --git a/src/flam3.h b/src/flam3.h index 3c7cda7..e94ec89 100644 --- a/src/flam3.h +++ b/src/flam3.h @@ -59,7 +59,7 @@ int flam3_get_palette(int palette_index, flam3_palette p, double hue_rotation); extern char *flam3_variation_names[]; -#define flam3_nvariations 98 +#define flam3_nvariations 99 #define flam3_nxforms 12 #define flam3_parent_fn_len 30 @@ -178,6 +178,7 @@ extern char *flam3_variation_names[]; #define VAR_COTH 95 #define VAR_AUGER 96 #define VAR_FLUX 97 +#define VAR_MOBIUS 98 typedef struct { @@ -389,6 +390,12 @@ typedef struct xform { /* Flux */ double flux_spread; + + /* Mobius */ + double mobius_re_a, mobius_im_a; + double mobius_re_b, mobius_im_b; + double mobius_re_c, mobius_im_c; + double mobius_re_d, mobius_im_d; /* If perspective is used, precalculate these values */ /* from the _angle and _dist */ diff --git a/src/interpolation.c b/src/interpolation.c index 6253800..c4e680b 100644 --- a/src/interpolation.c +++ b/src/interpolation.c @@ -582,6 +582,14 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, INTERP(xform[i].auger_freq); INTERP(xform[i].auger_scale); INTERP(xform[i].flux_spread); + INTERP(xform[i].mobius_re_a); + INTERP(xform[i].mobius_im_a); + INTERP(xform[i].mobius_re_b); + INTERP(xform[i].mobius_im_b); + INTERP(xform[i].mobius_re_c); + INTERP(xform[i].mobius_im_c); + INTERP(xform[i].mobius_re_d); + INTERP(xform[i].mobius_im_d); for (j = 0; j < flam3_nvariations; j++) INTERP(xform[i].var[j]); diff --git a/src/parser.c b/src/parser.c index a36b6cb..03f9bd0 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1215,6 +1215,22 @@ int parse_xform_xml(xmlNode *chld_node,flam3_xform *this_xform, int *num_xaos, this_xform->auger_scale = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"flux_spread")) { this_xform->flux_spread = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Re_A") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_re_a")) { + this_xform->mobius_re_a = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Re_B") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_re_b")) { + this_xform->mobius_re_b = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Re_C") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_re_c")) { + this_xform->mobius_re_c = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Re_D") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_re_d")) { + this_xform->mobius_re_d = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Im_A") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_im_a")) { + this_xform->mobius_im_a = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Im_B") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_im_b")) { + this_xform->mobius_im_b = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Im_C") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_im_c")) { + this_xform->mobius_im_c = flam3_atof(att_str); + } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"Im_D") || !xmlStrcmp(cur_att->name, (const xmlChar *)"mobius_im_d")) { + this_xform->mobius_im_d = flam3_atof(att_str); } else { int v = var2n((char *) cur_att->name); if (v != flam3_variation_none) diff --git a/src/variations.c b/src/variations.c index 4d26dd9..cc5c4c3 100644 --- a/src/variations.c +++ b/src/variations.c @@ -131,6 +131,7 @@ char *flam3_variation_names[1+flam3_nvariations] = { "coth", "auger", "flux", + "mobius", 0 }; @@ -1922,6 +1923,23 @@ void var97_flux (flam3_iter_helper *f, double weight) { f->p1 += avgr * sin(avga); } +void var98_mobius (flam3_iter_helper *f, double weight) { + + // Mobius, by eralex + double re_u, im_u, re_v, im_v, rad_v; + + re_u = f->xform->mobius_re_a * f->tx - f->xform->mobius_im_a * f->ty + f->xform->mobius_re_b; + im_u = f->xform->mobius_re_a * f->ty + f->xform->mobius_im_a * f->tx + f->xform->mobius_im_b; + re_v = f->xform->mobius_re_c * f->tx - f->xform->mobius_im_c * f->ty + f->xform->mobius_re_d; + im_v = f->xform->mobius_re_c * f->ty + f->xform->mobius_im_c * f->tx + f->xform->mobius_im_d; + + rad_v = weight / (re_v*re_v + im_v*im_v); + + f->p0 += rad_v * (re_u*re_v + im_u*im_v); + f->p1 += rad_v * (im_u*re_v - re_u*im_v); +} + + /* Precalc functions */ void perspective_precalc(flam3_xform *xf) { @@ -2359,6 +2377,8 @@ int apply_xform(flam3_genome *cp, int fn, double *p, double *q, randctx *rc) var96_auger(&f, weight); break; case (VAR_FLUX): var97_flux(&f, weight); break; + case (VAR_MOBIUS): + var98_mobius(&f, weight); break; } } @@ -2533,5 +2553,14 @@ void initialize_xforms(flam3_genome *thiscp, int start_here) { thiscp->xform[i].super_shape_holes = 0.0; thiscp->xform[i].conic_eccentricity = 1.0; thiscp->xform[i].conic_holes = 0.0; + + thiscp->xform[i].mobius_re_a = 0.0; + thiscp->xform[i].mobius_re_b = 0.0; + thiscp->xform[i].mobius_re_c = 0.0; + thiscp->xform[i].mobius_re_d = 0.0; + thiscp->xform[i].mobius_im_a = 0.0; + thiscp->xform[i].mobius_im_b = 0.0; + thiscp->xform[i].mobius_im_c = 0.0; + thiscp->xform[i].mobius_im_d = 0.0; } } diff --git a/src/variations.h b/src/variations.h index c44ea88..a0c0b2c 100644 --- a/src/variations.h +++ b/src/variations.h @@ -122,6 +122,7 @@ void var94_csch (flam3_iter_helper *f, double weight); void var95_coth (flam3_iter_helper *f, double weight); void var96_auger (flam3_iter_helper *f, double weight); void var97_flux (flam3_iter_helper *f, double weight); +void var98_mobius (flam3_iter_helper *f, double weight); /* Precalculation functions */ void perspective_precalc(flam3_xform *xf); -- cgit v1.2.3