Search in sources :

Example 41 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class CollideoscopeFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* collideoscope by Michael Faber, http://michaelfaber.deviantart.com/art/Collideoscope-251624597 */
    double a = atan2(pAffineTP.y, pAffineTP.x);
    double r = pAmount * sqrt(sqr(pAffineTP.x) + sqr(pAffineTP.y));
    int alt;
    if (a >= 0.0) {
        alt = (int) (a * kn_pi);
        if (alt % 2 == 0) {
            a = alt * pi_kn + fmod(ka_kn + a, pi_kn);
        } else {
            a = alt * pi_kn + fmod(-ka_kn + a, pi_kn);
        }
    } else {
        alt = (int) (-a * kn_pi);
        if (alt % 2 != 0) {
            a = -(alt * pi_kn + fmod(-ka_kn - a, pi_kn));
        } else {
            a = -(alt * pi_kn + fmod(ka_kn - a, pi_kn));
        }
    }
    double s = sin(a);
    double c = cos(a);
    pVarTP.x += r * c;
    pVarTP.y += r * s;
    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 42 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class MinkQMFunc method transform.

public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    double mnkX = pAffineTP.x;
    double mnkY = pAffineTP.y;
    int is = 0;
    if (mnkX < 0) {
        mnkX = -mnkX;
        is = 1;
    }
    if ((mnkX > 0.) && (mnkX < 1.)) {
        mnkX = minkowski(mnkX);
    }
    if (is == 1) {
        mnkX = -mnkX;
        is = 0;
    }
    if (mnkY < 0) {
        mnkY = -mnkY;
        is = 1;
    }
    if ((mnkY > 0.) && (mnkY < 1.)) {
        mnkY = minkowski(mnkY);
    }
    if (is == 1) {
        mnkY = -mnkY;
    }
    pVarTP.x += pAmount * mnkX;
    pVarTP.y += pAmount * mnkY;
    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 43 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint 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 44 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class PostBumpMapWFFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    double x = (pAffineTP.x - offsetX + 1.0) / scaleX * 0.5 * (double) (imgWidth - 1);
    double y = (pAffineTP.y - offsetY + 1.0) / scaleY * 0.5 * (double) (imgHeight - 1);
    double dz = offsetZ;
    int ix = Tools.FTOI(x);
    int iy = Tools.FTOI(y);
    if (ix >= 0 && ix < imgWidth && iy >= 0 && iy < imgHeight) {
        double intensity;
        if (bumpMap instanceof SimpleImage) {
            toolPixel.setARGBValue(((SimpleImage) bumpMap).getARGBValue(ix, iy));
            double r = toolPixel.r;
            double g = toolPixel.g;
            double b = toolPixel.b;
            intensity = (0.299 * r + 0.588 * g + 0.113 * b) / 255.0;
        } else {
            ((SimpleHDRImage) bumpMap).getRGBValues(rgbArray, ix, iy);
            double r = rgbArray[0];
            double g = rgbArray[0];
            double b = rgbArray[0];
            intensity = (0.299 * r + 0.588 * g + 0.113 * b);
        }
        dz += scaleZ * intensity;
        if (resetZ != 0) {
            pVarTP.z = dz;
        } else {
            pVarTP.z += dz;
        }
    }
}
Also used : SimpleHDRImage(org.jwildfire.image.SimpleHDRImage) SimpleImage(org.jwildfire.image.SimpleImage) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 45 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class Julia3DFunc method transformFunction.

public void transformFunction(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    double z = pAffineTP.z / absPower;
    double r2d = pAffineTP.x * pAffineTP.x + pAffineTP.y * pAffineTP.y;
    double r = pAmount * pow(r2d + z * z, cPower);
    double r2 = r * sqrt(r2d);
    int rnd = (int) (pContext.random() * absPower);
    double angle = (atan2(pAffineTP.y, pAffineTP.x) + 2 * M_PI * rnd) / (double) power;
    sinAndCos(angle, sina, cosa);
    pVarTP.x += r2 * cosa.value;
    pVarTP.y += r2 * sina.value;
    pVarTP.z += r * z;
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Aggregations

XYZPoint (org.jwildfire.create.tina.base.XYZPoint)102 XForm (org.jwildfire.create.tina.base.XForm)16 Layer (org.jwildfire.create.tina.base.Layer)13 Test (org.junit.Test)4 VectorD (org.jwildfire.base.mathlib.VecMathLib.VectorD)4 Flame (org.jwildfire.create.tina.base.Flame)4 ZigguratRandomGenerator (org.jwildfire.create.tina.random.ZigguratRandomGenerator)4 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)4 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)4 SimpleImage (org.jwildfire.image.SimpleImage)4 Complex (org.jwildfire.base.mathlib.Complex)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 Face (org.jwildfire.create.tina.variation.mesh.Face)2 Vertex (org.jwildfire.create.tina.variation.mesh.Vertex)2 VertexWithUV (org.jwildfire.create.tina.variation.mesh.VertexWithUV)2 RenderColor (org.jwildfire.create.tina.palette.RenderColor)1 CannabisCurveWFFunc (org.jwildfire.create.tina.variation.CannabisCurveWFFunc)1 CloverLeafWFFunc (org.jwildfire.create.tina.variation.CloverLeafWFFunc)1 DCPerlinFunc (org.jwildfire.create.tina.variation.DCPerlinFunc)1 FlowerFunc (org.jwildfire.create.tina.variation.FlowerFunc)1