From 933c9a4532637d1373f3299035f62e041c495d87 Mon Sep 17 00:00:00 2001 From: Erik Reckase Date: Wed, 23 Jun 2010 10:31:31 +0000 Subject: Added flux variation. git-svn-id: https://flam3.googlecode.com/svn/trunk@15 77852712-ef1d-11de-8684-7d64432d61a3 --- src/flam3.c | 19 ++++++++++++++++++- src/flam3.h | 6 +++++- src/interpolation.c | 1 + src/parser.c | 2 ++ src/variations.c | 26 +++++++++++++++++++++----- src/variations.h | 1 + 6 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/flam3.c b/src/flam3.c index 3525a48..959833a 100644 --- a/src/flam3.c +++ b/src/flam3.c @@ -673,6 +673,7 @@ void apply_motion_parameters(flam3_xform *xf, flam3_xform *addto, double blend) APPMOT(auger_weight); APPMOT(auger_freq); APPMOT(auger_scale); + APPMOT(flux_spread); for (j = 0; j < flam3_nvariations; j++) APPMOT(var[j]); @@ -961,6 +962,9 @@ void flam3_copy_params(flam3_xform *dest, flam3_xform *src, int varn) { dest->auger_weight = src->auger_weight; dest->auger_freq = src->auger_freq; dest->auger_scale = src->auger_scale; + } else if (varn==VAR_FLUX) { + /* flux */ + dest->flux_spread = src->flux_spread; } } @@ -1799,7 +1803,7 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub int cell_var=0,cpow_var=0,curve_var=0,escher_var=0,lazys_var=0; 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; + int wedgeS_var=0,whorl_var=0,waves2_var=0,auger_var=0,flux_var=0; int j; int lnv; @@ -1914,6 +1918,8 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub waves2_var=1; else if (j==VAR_AUGER) auger_var=1; + else if (j==VAR_FLUX) + flux_var=1; } } @@ -2129,6 +2135,9 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub fprintf(f, "auger_scale=\"%g\" ", x->auger_scale); } + if (flux_var==1) + fprintf(f, "flux_spread=\"%g\" ", x->flux_spread); + fprintf(f, "coefs=\""); for (j = 0; j < 3; j++) { if (j) fprintf(f, " "); @@ -2284,6 +2293,8 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub PRINTNON(auger_weight); PRINTNON(auger_freq); PRINTNON(auger_scale); + + PRINTNON(flux_spread); if (!zero_matrix(x->c)) { fprintf(f, "coefs=\""); @@ -3343,6 +3354,12 @@ void flam3_random(flam3_genome *cp, int *ivars, int ivars_n, int sym, int spec_x cp->xform[i].auger_scale = flam3_random01(); } + if (cp->xform[i].var[VAR_FLUX] > 0) { + /* Create random params for flux */ + cp->xform[i].flux_spread = 0.5 + flam3_random01()/2.0; + } + + } /* Randomly add symmetry (but not if we've already added a final xform) */ diff --git a/src/flam3.h b/src/flam3.h index 8d75e39..7a636a4 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 97 +#define flam3_nvariations 98 #define flam3_nxforms 12 #define flam3_parent_fn_len 30 @@ -177,6 +177,7 @@ extern char *flam3_variation_names[]; #define VAR_CSCH 94 #define VAR_COTH 95 #define VAR_AUGER 96 +#define VAR_FLUX 97 typedef struct { @@ -385,6 +386,9 @@ typedef struct xform { /* Auger */ double auger_sym, auger_weight; double auger_freq, auger_scale; + + /* Flux */ + double flux_spread; /* If perspective is used, precalculate these values */ /* from the _angle and _dist */ diff --git a/src/interpolation.c b/src/interpolation.c index 0ed3bf6..7a2303d 100644 --- a/src/interpolation.c +++ b/src/interpolation.c @@ -577,6 +577,7 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, INTERP(xform[i].auger_weight); INTERP(xform[i].auger_freq); INTERP(xform[i].auger_scale); + INTERP(xform[i].flux_spread); for (j = 0; j < flam3_nvariations; j++) INTERP(xform[i].var[j]); diff --git a/src/parser.c b/src/parser.c index 272f212..e28669a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1211,6 +1211,8 @@ int parse_xform_xml(xmlNode *chld_node,flam3_xform *this_xform, int *num_xaos, this_xform->auger_sym = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"auger_scale")) { 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 { int v = var2n((char *) cur_att->name); if (v != flam3_variation_none) diff --git a/src/variations.c b/src/variations.c index e40c48f..4d26dd9 100644 --- a/src/variations.c +++ b/src/variations.c @@ -130,6 +130,7 @@ char *flam3_variation_names[1+flam3_nvariations] = { "csch", "coth", "auger", + "flux", 0 }; @@ -1906,6 +1907,21 @@ void var96_auger (flam3_iter_helper *f, double weight) { f->p1 += weight * dy; } +void var97_flux (flam3_iter_helper *f, double weight) { + + // Flux, by meckie + double xpw = f->tx + weight; + double xmw = f->tx - weight; + double avgr = weight * (2 + f->xform->flux_spread) * sqrt( sqrt(f->ty*f->ty + xpw*xpw) / sqrt(f->ty*f->ty + xmw*xmw)); + double avga = ( atan2(f->ty, xmw) - atan2(f->ty,xpw) ) * 0.5; + + double s = sin(avga); + double c = cos(avga); + + f->p0 += avgr * cos(avga); + f->p1 += avgr * sin(avga); +} + /* Precalc functions */ void perspective_precalc(flam3_xform *xf) { @@ -2104,13 +2120,9 @@ int apply_xform(flam3_genome *cp, int fn, double *p, double *q, randctx *rc) f.rc = rc; -// s = 1.0-2.0*cp->xform[fn].color_speed; -// s1 = 0.5 - 0.5 * s; s1 = cp->xform[fn].color_speed; - s = 1.0 - 2.0*s1; - next_color = (p[2] + cp->xform[fn].color) * s1 + s * p[2]; - q[2] = next_color; + q[2] = s1 * cp->xform[fn].color + (1.0-s1) * p[2]; q[3] = cp->xform[fn].vis_adjusted; //fprintf(stderr,"%d : %f %f %f\n",fn,cp->xform[fn].c[0][0],cp->xform[fn].c[1][0],cp->xform[fn].c[2][0]); @@ -2345,6 +2357,8 @@ int apply_xform(flam3_genome *cp, int fn, double *p, double *q, randctx *rc) var95_coth(&f, weight); break; case (VAR_AUGER): var96_auger(&f, weight); break; + case (VAR_FLUX): + var97_flux(&f, weight); break; } } @@ -2486,6 +2500,8 @@ void initialize_xforms(flam3_genome *thiscp, int start_here) { thiscp->xform[i].auger_weight = 0.5; thiscp->xform[i].auger_sym = 0.0; thiscp->xform[i].auger_scale = 1.0; + + thiscp->xform[i].flux_spread = 0.0; thiscp->xform[i].julian_power = 1.0; thiscp->xform[i].julian_dist = 1.0; diff --git a/src/variations.h b/src/variations.h index c724b58..c44ea88 100644 --- a/src/variations.h +++ b/src/variations.h @@ -121,6 +121,7 @@ void var93_sech (flam3_iter_helper *f, double weight); 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); /* Precalculation functions */ void perspective_precalc(flam3_xform *xf); -- cgit v1.2.3