use of org.nfunk.jep.type.Complex in project JWildfire by thargor6.
the class KleinGroupFunc method calcRileyGenerators.
/*
* Riley recipe only uses one complex parameter, c
* So using a_re and a_im to construct c, and ignoring b_re and b_im parameters
*/
public Complex[][] calcRileyGenerators() {
Complex c = new Complex(a_re, a_im);
Complex[] mat_a = new Complex[] { re1, zero, c, re1 };
Complex[] mat_b = new Complex[] { re1, re2, zero, re1 };
Complex[][] generators = new Complex[2][4];
generators[0] = mat_a;
generators[1] = mat_b;
return generators;
}
use of org.nfunk.jep.type.Complex in project JWildfire by thargor6.
the class KleinGroupFunc method calcMaskitGenerators.
/*
* for Maskit recipe using complex parameter a for mu rather than for Trace(generator_a)
* Trace(generator_a) = ta = -i*mu
*/
public Complex[][] calcMaskitGenerators() {
Complex mu = new Complex(a_re, a_im);
Complex[] mat_a = new Complex[] { mu.mul(-1).mul(im1), im1.mul(-1), im1.mul(-1), zero };
Complex[] mat_b = new Complex[] { re1, re2, zero, re1 };
Complex[][] generators = new Complex[2][4];
generators[0] = mat_a;
generators[1] = mat_b;
return generators;
}
use of org.nfunk.jep.type.Complex in project JWildfire by thargor6.
the class KleinGroupFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// if avoid_reversals is false,
// randomly pick one of the four calculated Mobius transformation matrices, a, b, A, B where A = inverse(a), B = inverse(b)
//
// if avoid_reversals is true trying to give the variation some internal "memory"
// for a first pass, remember last used matrix (out of a, b, A, B)
// and use that to choose different sets of matrices to randomly sample from
// for example to avoid getting successive pairs of matrix m and inverse M, which
// would cancel each other out: m(z)M(z) = z
// so selecting randomly each time from the set of transforms that won't cause a reversal
Complex[][] mtransforms;
// (aA, bB, Aa, Bb)
if (avoid_reversal) {
if (prev_matrix == mat_a) {
mtransforms = not_A;
} else if (prev_matrix == mat_inv_a) {
mtransforms = not_a;
} else if (prev_matrix == mat_b) {
mtransforms = not_B;
} else if (prev_matrix == mat_inv_b) {
mtransforms = not_b;
} else // shouldn't get here...
{
mtransforms = all_matrices;
}
} else {
mtransforms = all_matrices;
}
// randomly select a matrix from the list of matrices
int mindex = pContext.random(mtransforms.length);
Complex[] mat = mtransforms[mindex];
// then use selected matrix for Mobius transformation:
// f(z) = (az + b) / (cz + d);
// for the generator matrices
// [0, 1, 2, 3] = [a, b, c, d] ==> f(z)= (az+b)/(cz+d)
//
double xin = pAffineTP.x;
double yin = pAffineTP.y;
xin /= pAmount;
yin /= pAmount;
Complex win = new Complex(xin, yin);
Complex a = mat[0];
Complex b = mat[1];
Complex c = mat[2];
Complex d = mat[3];
Complex wout = win.mul(a).add(b).div(win.mul(c).add(d));
pVarTP.x += pAmount * wout.re();
pVarTP.y += pAmount * wout.im();
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
prev_matrix = mat;
}