Search in sources :

Example 1 with Complex

use of org.jwildfire.base.mathlib.Complex in project JWildfire by thargor6.

the class PolylogarithmFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* polylogarithm by dark-beam */
    // approx (very good) of Li[n](z) for n > 1
    double vv = pAmount;
    Complex z = new Complex(pAffineTP.x, pAffineTP.y);
    z.Pow(zpow);
    z.Save();
    if (z.Mag2() > 250000.0 || N >= 20) {
        // no convergence, or N too big... When N is big then Li tends to z
        pVarTP.x += vv * z.re;
        pVarTP.y += vv * z.im;
        return;
    }
    Complex LiN = new Complex();
    int i;
    Complex T = new Complex();
    Complex zPl1 = new Complex(z);
    if (z.Mag2() < 0.07) {
        // normal series. Li = sum((z^k)/(k^n))
        for (i = 1; i < 20; i++) {
            T.Copy(new Complex(pow(i, N)));
            T.DivR(z);
            LiN.Add(T);
            z.NextPow();
        }
        pVarTP.x += vv * LiN.re;
        pVarTP.y += vv * LiN.im;
        return;
    }
    // Crandall method (very simple and fast!) that uses Erdelyi series
    // from now on we will use ln(z) only so switch to it
    z.Log();
    z.Save();
    z.One();
    for (i = 0; i < 20; i++) {
        double zee = Riem.Z((int) N - i);
        if (zee != 0.0) {
            T.Copy(z);
            T.Scale(zee / (cern.jet.math.Arithmetic.longFactorial(i)));
            LiN.Add(T);
        }
        if (i == N - 1) {
            zPl1.Copy(z);
        }
        z.NextPow();
    }
    // back to log(z) again...
    z.Restore();
    z.Neg();
    z.Log();
    // -log(-log(z)) must be added now...
    z.Neg();
    z.re += HSTerm;
    T.Copy(z);
    z.Copy(zPl1);
    z.Scale(1.0 / cern.jet.math.Arithmetic.longFactorial((int) N - 1));
    z.Mul(T);
    LiN.Add(z);
    pVarTP.x += vv * LiN.re;
    pVarTP.y += vv * LiN.im;
    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint) Complex(org.jwildfire.base.mathlib.Complex)

Example 2 with Complex

use of org.jwildfire.base.mathlib.Complex in project JWildfire by thargor6.

the class CrownFunc method transform.

public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    // Roger Bagula  Reference:
    // http://paulbourke.net/fractals/crown/
    double x, y, z;
    double t = (-M_PI + 2.0 * M_PI * pContext.random());
    Complex wt = new Complex(0.0, 0.0);
    for (int k = 1; k < 15; k++) {
        double denom = MathLib.pow(a, b * k);
        double th = MathLib.pow(a, (double) k) * MathLib.pow(-1.0, (double) k) * t;
        wt.Add(new Complex(sin(th) / denom, cos(th) / denom));
    }
    x = wt.re;
    y = wt.im;
    z = MathLib.pow(wt.Mag2(), 2);
    pVarTP.x += x * pAmount;
    pVarTP.y += y * pAmount;
    pVarTP.z += z * pAmount;
    pVarTP.color = fmod(fabs((sqr(pVarTP.x) + sqr(pVarTP.y))), 1.0);
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint) Complex(org.jwildfire.base.mathlib.Complex)

Aggregations

Complex (org.jwildfire.base.mathlib.Complex)2 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)2