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;
}
}
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;
}
}
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;
}
}
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;
}
}
}
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;
}
Aggregations