Title: Help! Newton fractal smooth shading Post by: Softology on January 17, 2011, 05:45:40 AM Hello All,
I have been getting back into root finding fractals (Newton, Halley and Schroder methods of root finding to generate fractals). Getting the root finding code to work was realtively easy. Got to love Wolfram Alpha that can spit out a second derivative within a blink of an eye. My issue is trying to get a formula for getting smooth color shading (ie no visible banding). Can anyone assist? I have tried the formulas listed here http://www.hiddendimension.com/FractalMath/Convergent_Fractals_Main.html and think I have them correct code wise but get blank images and when debugging the "Sn" value it always ends up as a "NAN" value, so I must be doing something wrong. Does anyone have a snippet of code that works for the root finding fractals? I have the z and lastz and magz values, but I need a good formula to get the smooth color. The closest I got was .... floatval:=ln(cabs(cdiv(cone,csub(lastz,z))))/5.7456 floatval:=1-abs(floatval-trunc(floatval)) Which gets a value between 0 and 1 to smooth out the iterations, but this never worked 100% correctly and I have no idea why the /5.7456 was necessary. It came from trial and error and is very picky with iteration counts and the formulas being used. Any tips would be very appreciated. Thanks, Jason. Title: Re: Help! Newton fractal smooth shading Post by: knighty on January 17, 2011, 02:55:15 PM Quote I have tried the formulas listed here http://www.hiddendimension.com/FractalMath/Convergent_Fractals_Main.html and think I have them correct code wise but get blank images and when debugging the "Sn" value it always ends up as a "NAN" value, so I must be doing something wrong. Maybe the problem comes from exp() function when using relatively big argument (say, its absolute value > 10000). here is an evaldraw implementation that seems to work. :)Code: (x,y){Title: Re: Help! Newton fractal smooth shading Post by: Softology on January 18, 2011, 03:40:56 AM Thanks for the code. It had the same issues. Must be something with my calculation code that differs.
Anyway I found another method for newton smooth coloring within the source code here http://www.chiark.greenend.org.uk/~sgtatham/newton/ that did the trick. It uses a few log calcs after the iteration loop, so it does not need the constant summing during each iteration. Jason. Title: Re: Help! Newton fractal smooth shading Post by: David Makin on January 18, 2011, 04:35:26 AM The standard Vepstas smoothing method can be adapted for areas of point convergence quite easily including using the *actual* convergence at bailout rather than an estimated value, for the fraction use:
If bailout is tested for using |#z-zold| against @smallbail then given: float clp = log(-0.5*log(@smallbail)) Then use either: float f = real( (clp-log(-0.5*log(|#z-zold|))) / log(log(|#z-zold|)/log(|zold-zolder|)) ) Or: float f = real( (clp-log(-0.5*log(|#z-@fixedval|))) / log(log(|#z-@fixedval|)/log(|zold-@fixedval|)) ) Where |x+i*y| is x^2+y^2 and in the second case @fixedval is a known point attractor, #z is the final value of z, zold the penultimate and zolder the one before that. Title: Re: Help! Newton fractal smooth shading Post by: Softology on January 31, 2011, 12:36:46 AM Thanks David. After I combined your method with the method from the website I linked to I finally have images with no banding or artifcats across many types of formulas and root-finding methods. In case this may help someone else in the future, the final code was; dist0:=cdistsquared(lastz2,lastz); dist1:=cdistsquared(lastz,z); logt:=ln(tolerance); log0:=ln(dist0); log1:=ln(dist1); floatval:=(logt-log0)/(log1-log0); cdistsquared returns the distance between the points without the sqrt calc. floatval is the fractional iteration count you use to smooth the colors Jason. |