|
|
waggy <hon### [at] handbasketorg> wrote:
> I previosly wrote:
> > I also plan to flirt with insanity by taking a crack at reworking it for
> > full quaternion power exponents.
>
> Well, something cracked, all right. Since I had to recompile anyway, I
> went ahead and coded a full quaternion power version. Once I worked out
> the math (or more accurately, it worked me out), the resulting algorithm
> isn't that much more computationally intensive than the old White and
> Naylander formulas, and may even be a touch faster. (It would still be
> too much to code in SDL unless I can learn how to build functions from
> macros, or write an external script to make the SDL function.)
....
David,
If you would like to see how hyou can build functions with macros,
then below is a macro that produces a function that is similar to
your recursive (non-quaternion) Mandelbrot function.
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#macro MandelBulbFunction(R_Pwr, R_BO, Ph_Pwr, Ph_Phase, Th_Pwr, Max_Iter)
#local ln_R_BO = ln(R_BO);
#local ln_R_Pwr = ln(R_Pwr);
#local J = Max_Iter - 1;
#local MB_Fns = array[Max_Iter][2]
#local I = Max_Iter;
#while (I > 0)
#local I = I - 1;
#local MB_Fns[I][1] =
function(x, y, z, _r, _rp, _ph, _th) {
#if (I = J)
0
#else
select(
_r - R_BO,
MB_Fns[I+1][0](
x,
y,
z,
x + _rp*cos(_ph)*cos(_th),
y + _rp*sin(_ph),
z + _rp*cos(_ph)*sin(_th)
),
1/(I - ln(ln(_r)/ln_R_BO)/ln_R_Pwr)
)
#end // if
}
#local MB_Fns[I][0] =
function(x, y, z, _ix, _iy, _iz) {
MB_Fns[I][1](
x,
y,
z,
f_r(_ix, _iy, _iz),
pow(f_r(_ix, _iy, _iz), R_Pwr),
Ph_Pwr*(f_ph(_ix, _iy, _iz) + Ph_Phase),
Th_Pwr*f_th(_ix, _iy, _iz)
)
}
#end // while
function { MB_Fns[0][0](x, y, z, x, y, z) }
#end // macro MandelBulbFunction
// It can be used like this:
#declare MandelBulbFn = MandelBulbFunction(8, 3, 8, pi/2, 8, 5)
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|