Welcome to Fractal Forums

Fractal Software => Mandelbulb 3d => Topic started by: Alef on March 25, 2012, 09:39:34 PM




Title: Possible modification an unit vector addition
Post by: Alef on March 25, 2012, 09:39:34 PM
Looking at last two posts of time tested 2D formulas should be in 3D I just could not to post this possible _modification. It is not an age old time tested formula, posted in december, and found after few beers.  :beer: http://www.fractalforums.com/index.php?topic=4881.msg39515#msg39515 (http://www.fractalforums.com/index.php?topic=4881.msg39515#msg39515)
They say intoxication connects your soul to celestial spheres where information is obtained, but in a dangerous way.

I was trying implementing amazingbox formula together with some variations to play with. Well, this is with bug filled double y no z folded amazingbox, and not with normal amazingbox.

z=amazingbox (z) + c
if |z| !=0
z=z/cabs(z) * complex(-0.1,0.5) + z  (division first seems to be faster.)
else
z=z+1.0E-10

Positive factor shrunk the fractal, negative bloated it, imaginary value rotated fractal. Alsou modification made fractal more natural floral looking. Quaternionic factor slowed it, so I kept it complex.
(http://www.ljplus.ru/img4/a/s/asdam/UV_mandelbox_grass_300.jpg)

And nice julia.
(http://www.ljplus.ru/img4/a/s/asdam/2_UV_mandelbox_julia_300.jpg)

Alsou tested unmathematical things from TMA2.ufm. Round function truncated the render.
z=mandelbox (z) +c;
if round(z) !=0
z=z/round(z) * complex(0,1) + z
(http://www.ljplus.ru/img4/a/s/asdam/3_UV_mandelbox_round_300.jpg)

Alsou after a mandelbulb formula and factor j=1 got this plant curved bulb.
z= mandelbulb(z)+c
z=z/cabs(z)* quaternion(-0.2,0,1,0) +z
(http://www.ljplus.ru/img4/a/s/asdam/4_Mandelbulb_fir_300.jpg)

p.s.
Yeah, there are just two who can implement, and they don't want to lower quality standarts;) And its pretty time consuming. So just as notice, until there will be no ideas for 249th formula. The code are in mandelbulb and amazingbox http://www.chaospro.de/formulas/display.php?fileid=222 (http://www.chaospro.de/formulas/display.php?fileid=222)


Title: Re: Possible modification of unit vector addition
Post by: Alef on March 28, 2012, 06:59:57 PM
Allredy posted 7 degree mandelbulb modified by z/round(z), just to show how this works with mandelbulbs.
z=mandelbulb^7(z)+c
z=(  z/round(z)  )*quaternion(1,0,0,0) + z
(http://www.ljplus.ru/img4/a/s/asdam/_Marblbulbl.jpg)



And an unit vector addition modification of normal bug free amazingbox / mandelbox with fold=1, min r=0.5, scale=-1.5 First modulus squared as || in Ultra Fractal, second a bitt modified modulus.
z=amazingbox(z) +c
z=(  z/|z|  )*complex(0.6,0) + z
(http://www.ljplus.ru/img4/a/s/asdam/real_uv_box_2_300.jpg)
(http://www.ljplus.ru/img4/a/s/asdam/real_uv_box_6_300.jpg)


Title: Re: Possible modification an unit vector addition
Post by: DarkBeam on March 29, 2012, 11:37:35 AM
It is a nice idea, a more consistent formula may be;

s=amazingbox (s) + c
m = cabs3d(s) = s.x^2 + ... + s.z^2
if m < 1e-23
s=s/m * Rotate(3angles) + s  (division first seems to be faster.) (impossible!)  :dink:

// else (not needed)
// z=z+1.0E-10 (not needed)

I can not do it btw for now :-\


Title: Re: Possible modification an unit vector addition
Post by: Alef on March 31, 2012, 08:27:44 PM
It seems much smother code, just that with else z=z+1.0E-10 was simpler to write down :embarrass:  

Maybe it sometimes got faster, sometimes not, realy not shure;)
In help files I found claims that functions using many registers (or something like that, I m not a programmer) such us sqr should be placed first, and then must go simpler functions like multiplication. Becouse then processor can use its registers or something alike (used for sqr) for a multiplication. If multiplication goes first, processor still has to keep sqr function data.  
I was thinking that division too could have such property. At least having old PC helps to test speed;)

the same pics
http://www.fractalforums.com/images-showcase-(rate-my-fractal)/mandelbox-tree/ (http://www.fractalforums.com/images-showcase-(rate-my-fractal)/mandelbox-tree/)


Title: Re: Possible modification an unit vector addition
Post by: DarkBeam on March 31, 2012, 11:58:05 PM
Dunno, normally I code sqr with a simple fpu instr.:
fmul st,st
that computes in a very small time ;)
See you and thanks friend


Title: Re: Possible modification an unit vector addition
Post by: Alef on April 06, 2012, 03:28:41 PM
Sqr are very fast even on old PC. So in Chaos pro sqr(sqr(z)) compiled is by some percents faster than long multiplication of z*z*z*z or sqr(z)*sqr(z), throught the code then are very ugly;)
Not shure what instructions it uses, but I could guess, the same.


Title: Re: Possible modification an unit vector addition
Post by: DarkBeam on April 06, 2012, 05:12:05 PM
I have added it to my formulas, try it and see what happens. A bit more flexible - custom rotation and scale of your term. ;D Luca

Code:
A cool 3D transform suggested by Asdam in the forums;

vec3d += Scale * Rotation * vec3d / cabs3d(vec3d)

Where cabs3d(x,y,z) = sqrt(x*x + y*y + z*z)

Somewhat similar to a pinch/punch effect.

LucaGN & Asdam 2012


Title: Re: Possible modification an unit vector addition
Post by: David Makin on April 06, 2012, 07:50:07 PM
Sqr are very fast even on old PC. So in Chaos pro sqr(sqr(z)) compiled is by some percents faster than long multiplication of z*z*z*z or sqr(z)*sqr(z), throught the code then are very ugly;)
Not shure what instructions it uses, but I could guess, the same.

If coding for a decent compiler with optimisations set correctly then the compiler *ought* to choose the best method anyway.....and does in some cases, however generally you only find that out by trial and error or if you actually wrote the compiler ;)


Title: Re: Possible modification an unit vector addition
Post by: Alef on April 16, 2012, 06:14:55 PM
Copy past from helpfiles.

Quote
modifying your expressions so that the FPU is used more efficiently. That means a*sin(c) will be transformed into sin(c)*a. Why is sin(c)*a faster? Well, what happens if you calculate a*sin(c)? At first a gets fetched into the internal registers. After that c gets fetched. Then the program recognizes that the sine of c should be calculated. The Intel-Pentium FPU has only 8 registers. Now 4 registers are already used: two by a and two by c. In order to calculate sin(c) the routines need 5 registers. Thus a must be unloaded, sin(c) calculated, a loaded and then the multiplication can be done.
But if the expression is sin(c)*a, then c gets fetched into the internal registers. The sine of c can be calculated, because 6 registers are free. After having calculated sin(c) only two registers are blocked (by sin(c), i.e. the result only). a can be fetched without problem, and the result can be multiplicated. As a general rule: Operators get exchanged so the most expensive operations are done at first.

elimitating constant expressions:

Helpfile stated that compiler eliminates nostant expressions, but I doubt that, at least loss of spead don't indicates this.)