Welcome to Fractal Forums

Fractal Software => Plugins => Topic started by: simon.snake on May 12, 2013, 12:24:13 AM




Title: New plugin started
Post by: simon.snake on May 12, 2013, 12:24:13 AM
I'm in the process of writing a plugin for a formula I wrote about here (http://www.fractalforums.com/index.php?topic=4881.msg60994#msg60994) which I have now got working up to 45 zooms (so I've still got the high precision bit to write). Will upload as soon as I get that bit done, unless I have a problem beforehand.

I've just had a play with it but I'm certain the julias are different to what I was getting in FractInt.

Here's an initial screenshot showing the new plugin:

(http://www.needanother.co.uk/uploads/Simon100A.png)


Title: Re: New plugin started
Post by: simon.snake on May 12, 2013, 06:01:07 PM
I've had no issues creating the initial plugin but the fixed high precision maths section just comes up blank (either completely black - e.g. reached infinity or blue - e.g. bailed out).

Also the julias are different to how they appeared on FractInt.

Here's the code for each section, I don't know what's wrong. Anyone see anything I've overlooked?

Firstly, the low precision stuff:

Code:
FXEXPORT int CalcJuliaFloat(int EquationID, struct FloatParams *pParams)
{
double zr = pParams->cr;
double zi = pParams->ci;
double JuliaR = pParams->JuliaR;
double JuliaI = pParams->JuliaI;
int MaxIters = pParams->MaxIters;
double OverFlowPoint = pParams->OverFlowPoint;
double zrsqr = 0;
double zisqr = 0;
double zrabs, ziabs, tempzi, tempzr;

int count = 0;
switch (EquationID)
{
case FT_Simon100A:
for (/**/; count < MaxIters && zrsqr + zisqr < OverFlowPoint; count++)
{
zrabs = abs(zr);
ziabs = abs(zi);
tempzi = zi*zrabs+zr*ziabs;
tempzr = zr*zrabs-zi*ziabs;
zi=tempzi;
zr=tempzr;
zrsqr = zr * zr;
zisqr = zi * zi;
zi = zr * zi * 2.0 + JuliaI;
zr = zrsqr - zisqr + JuliaR;

zisqr = zi * zi;
zrsqr = zr * zr;
}
break;
}

pParams->cr = zr;
pParams->ci = zi;

if (count > MaxIters)
{
// It is not legal to return a count value that is greater than MaxIters.
__debugbreak();
count = MaxIters;
}
if (count < 0)
{
// It is not legal to return a count value that is negative.
__debugbreak();
count = 0;
}

return count;
}

Secondly, the high precision stuff:

Code:
	// Initialize our numbers from the fixed-point data passed in.
HighPrecMath zr(pParams->cr + offset, precision);
HighPrecMath zi(pParams->ci + offset, precision);
HighPrecMath JuliaR(pParams->JuliaR + offset, precision);
HighPrecMath JuliaI(pParams->JuliaI + offset, precision);
int MaxIters = pParams->MaxIters;
HighPrecMath zrsqr = zr - zr;
HighPrecMath zisqr = zrsqr;
HighPrecMath zrabs = zr;
HighPrecMath ziabs = zi;
HighPrecMath tempzi = zi;
HighPrecMath tempzr = zr;
HighPrecMath zrziabs = zr;
HighPrecMath ziziabs = zi;

int count = 0;
switch (EquationID)
{
case FT_Simon100A:
for (/**/; count < MaxIters && !(zrsqr + zisqr).Overflow(); count++)
{
// Using *= and += instead of * and + avoids the creation of expensive
// temporaries and can be a very important optimization.
// Combining the fixed-point shifting of 'zi *= zr' with the shifting
// by one of zi (multiplication by two) can save some time.
zrabs = zr;
if(zrabs.IsNegative()) zrabs.negate();
ziabs = zi;
if(ziabs.IsNegative()) ziabs.negate();
tempzi = zi; tempzi *= zrabs;
zrziabs = zr; zrziabs *= ziabs;
tempzi += zrziabs;
tempzr = zr; tempzr *= zrabs;
ziziabs = zi; ziziabs *= ziabs;
tempzr -= ziziabs;
zi = tempzi;
zr = tempzr;

zrsqr = zr; zisqr *= zr;
zisqr = zi; zisqr *= zi;

zi *= zr;
zi <<= 1; zi += JuliaI; //zi = |zi * zr| * 2 - JuliaI;
zrsqr -= zisqr; zrsqr += JuliaR; zr = zrsqr; //zr = zrsqr - zisqr - JuliaR;
zisqr = zi; zisqr *= zi; // zisqr = zi * zi;
zrsqr *= zrsqr; // zrsqr = zr * zr;
}
break;
}

Hope it makes sense...


Title: Re: New plugin started
Post by: simon.snake on May 12, 2013, 07:58:18 PM
I found it. I was trying to square zr but assigned it to zisqr!


Title: Re: New plugin started
Post by: simon.snake on May 12, 2013, 08:20:57 PM
Here's a link to the 64-bit version of the plugin: Simon100A.dll (http://www.needanother.co.uk/uploads/Simon100A.dll)

It's incredibly slow in high precision but looks good.

Let me know if there's any problems. I've only got the express edition of C++ but I've 'adapted it' to allow me to compile 64-bit stuff by installing the windows driver development kit, and even though I've had to add a few paths to the library and include directories, it does compile.

I'll compile a 32-bit version as soon as I get a chance, but my phone line (and therefore internet) has been down all day, and using mobile data is incredibly slow.  Should be back up and working tomorrow evening...


Title: Re: New plugin started
Post by: cKleinhuis on May 12, 2013, 08:35:27 PM
well done, i wonder if there is a tutorial about how to create 64bit c# :)


Title: Re: New plugin started
Post by: panzerboy on May 13, 2013, 04:07:28 AM
Congratulations, you've joined an exclusive club of FX plugun writers.  :D

I'm currently trying to track down why there are extra artifacts in many plugins once you go into high-precision.
Ie turn off the guessing in advanced setting and see all the extra fine lines there are between the iterations bands.
My suspicion is that it has to do with the dodgy .overflow() method in high precision.
It just checks against the most significant word (the last) against a constant integer of 4.
If the value was 4.000 000 000 000 000 001 or less it wouldnt be detected as overflowing.
So far my attempts to fix this have just made the artifacts worse  :sad1:

Your plugiun request for the formula with a fixed number of iterations using the distance travelled looks like it would extremely slow.
The only way I know how to calculate the distance is to do pythagous for the triangle formed by each successive iterations coordinates.
You add up the hypotenuses for all the iterations, you get the total distance travelled.
That means coding a square root finding algorithm (iterative) for every iteration.


Title: Re: New plugin started
Post by: simon.snake on May 18, 2013, 04:55:15 PM
Unbelievably, I've only just been re-connected to the telephone network (and internet is back) so I'm now back, with more news.

As I've had no internet for a week, I've been converting some more formulae to plugins.  Once I wade through outstanding emails, check facebook, etc. I'll be able to write a new post (in this sub forum) with more ideas, and provide links to the new plugins...

Back soon...