@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// Jacobi-elliptic-DN by dark-beam, http://dark-beam.deviantart.com/art/Jacobi-elliptic-sn-cn-and-dn-Apoplugins-460783612
double NumX, NumY, Denom;
Jacobi_elliptic_result jac_x = new Jacobi_elliptic_result();
Jacobi_elliptic(pAffineTP.x, k, jac_x);
Jacobi_elliptic_result jac_y = new Jacobi_elliptic_result();
Jacobi_elliptic(pAffineTP.y, 1.0 - k, jac_y);
NumX = jac_x.dn * jac_y.cn * jac_y.dn;
NumY = -jac_x.cn * jac_x.sn * jac_y.sn * k;
Denom = sqr(jac_x.sn) * sqr(jac_y.sn) * k + sqr(jac_y.cn);