jwildfire.org

The official JWildfire forum
It is currently Sun Mar 24, 2019 6:07 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Bipolar2 and Elliptic2
PostPosted: Fri Nov 30, 2018 2:40 am 
Offline
User avatar

Joined: Sun May 31, 2015 2:39 pm
Posts: 568
Missy Gainer requested that I add more variables to bipolar so I did, and while I was at it I added variables to elliptic.

Bipolar
Code:
/*
  JWildfire - an image and animation processor written in Java 
  Copyright (C) 1995-2011 Andreas Maschke

  This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 
  General Public License as published by the Free Software Foundation; either version 2.1 of the 
  License, or (at your option) any later version.
 
  This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this software; 
  if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.variation;

import static org.jwildfire.base.mathlib.MathLib.M_2_PI;
import static org.jwildfire.base.mathlib.MathLib.M_PI;
import static org.jwildfire.base.mathlib.MathLib.M_PI_2;
import static org.jwildfire.base.mathlib.MathLib.atan2;
import static org.jwildfire.base.mathlib.MathLib.fmod;
import static org.jwildfire.base.mathlib.MathLib.log;

import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;

public class Bipolar2Func extends VariationFunc {
  private static final long serialVersionUID = 1L;

  private static final String PARAM_SHIFT = "shift";
  private static final String PARAM_A = "a";
  private static final String PARAM_B = "b";
  private static final String PARAM_C = "c";
  private static final String PARAM_D = "d";
  private static final String PARAM_E = "e";
  private static final String PARAM_F1 = "f1";
  private static final String PARAM_G1 = "g1";
  private static final String PARAM_H = "h";
  private static final String[] paramNames = { PARAM_SHIFT, PARAM_A, PARAM_B, PARAM_C, PARAM_D, PARAM_E, PARAM_F1, PARAM_G1, PARAM_H }; 
  
  

  private double shift = 0.0;
  private double a = 1.0;
  private double b = 2.0;
  private double c = 0.5;
  private double d = 1.0;
  private double e = 2.0;
  private double f1 = 0.25;
  private double g1 = 1.0;
  private double h = 1.0;
  @Override
  public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* Bipolar in the Apophysis Plugin Pack with variables added by Brad Stefanov */

    double x2y2 = (pAffineTP.x * pAffineTP.x + pAffineTP.y * pAffineTP.y)*g1;
    double t = x2y2 + a;
    double x2 = b * pAffineTP.x;
    double ps = -M_PI_2 * shift;
    double y = c * atan2(e * pAffineTP.y, x2y2 - d) + ps;

    if (y > M_PI_2) {
      y = -M_PI_2 + fmod(y + M_PI_2, M_PI);
    }
    else if (y < -M_PI_2) {
      y = M_PI_2 - fmod(M_PI_2 - y, M_PI);
    }

    double f = t + x2;
    double g = t - x2;

    if ((g == 0) || (f / g <= 0))
      return;
    pVarTP.x += pAmount * f1 * M_2_PI * log((t + x2) / (t - x2));
    pVarTP.y += pAmount * M_2_PI * y*h;
    if (pContext.isPreserveZCoordinate()) {
  pVarTP.z += pAmount * pAffineTP.z;
}
  }

  @Override
  public String[] getParameterNames() {
    return paramNames;
  }

  @Override
  public Object[] getParameterValues() {
    return new Object[] { shift, a, b, c, d, e, f1, g1, h };
  }

  @Override
  public void setParameter(String pName, double pValue) {
    if (PARAM_SHIFT.equalsIgnoreCase(pName))
      shift = pValue;
    else if (PARAM_A.equalsIgnoreCase(pName)) {
        a = pValue;
      }
      else if (PARAM_B.equalsIgnoreCase(pName)) {
        b = pValue;
      }
      else if (PARAM_C.equalsIgnoreCase(pName)) {
        c = pValue;
      }
      else if (PARAM_D.equalsIgnoreCase(pName)) {
        d = pValue;
      }
      else if (PARAM_E.equalsIgnoreCase(pName)) {
        e = pValue;
      }
      else if (PARAM_F1.equalsIgnoreCase(pName)) {
        f1 = pValue;
      }
      else if (PARAM_G1.equalsIgnoreCase(pName)) {
        g1 = pValue;
      }
      else if (PARAM_H.equalsIgnoreCase(pName)) {
        h = pValue;
      }
    else
      throw new IllegalArgumentException(pName);
  }

  @Override
  public String getName() {
    return "bipolar2";
  }

}
Elliptic
Code:
/*
  JWildfire - an image and animation processor written in Java 
  Copyright (C) 1995-2011 Andreas Maschke

  This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 
  General Public License as published by the Free Software Foundation; either version 2.1 of the 
  License, or (at your option) any later version.
 
  This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this software; 
  if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.variation;

import static org.jwildfire.base.mathlib.MathLib.SMALL_EPSILON;
import static org.jwildfire.base.mathlib.MathLib.M_PI;
import static org.jwildfire.base.mathlib.MathLib.M_PI_2;
import static org.jwildfire.base.mathlib.MathLib.atan2;
import static org.jwildfire.base.mathlib.MathLib.log;
import static org.jwildfire.base.mathlib.MathLib.sqrt;

import org.jwildfire.create.tina.base.Layer;
import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;

public class Elliptic2Func extends VariationFunc {
  private static final long serialVersionUID = 1L;
  

  private static final String PARAM_A1 = "a1";
  private static final String PARAM_A2 = "a2";
  private static final String PARAM_A3 = "a3";
  private static final String PARAM_B1 = "b1";
  private static final String PARAM_B2 = "b2";
  private static final String PARAM_C = "c";
  private static final String PARAM_D = "d";
  private static final String PARAM_E = "e";
  private static final String PARAM_F = "f";
  private static final String PARAM_G = "g";
  private static final String PARAM_H = "h";
  private static final String[] paramNames = {  PARAM_A1, PARAM_A2, PARAM_A3, PARAM_B1, PARAM_B2, PARAM_C, PARAM_D, PARAM_E, PARAM_F, PARAM_G, PARAM_H }; 
  
  


  private double a1 = 1.0;
  private double a2 = 1.0;
  private double a3 = 0.0;
  private double b1 = 2.0;
  private double b2 = 1.0;
  private double c = 0.5;
  private double d = 1.0;
  private double e = 0.5;
  private double f = 1.0;
  private double g = 1.0;
  private double h = 2.0;  

  private double sqrt_safe(double x) {
    return (x < SMALL_EPSILON) ? 0.0 : sqrt(x);
  }

  @Override
  public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
	  /* Elliptic with variables added by Brad Stefanov */
	  
    double tmp = pAffineTP.y * pAffineTP.y + pAffineTP.x * pAffineTP.x + a1;
    double x2 = b1 * pAffineTP.x;
    double xmax = c * (sqrt(tmp + x2) + sqrt(tmp - x2));

    double a = pAffineTP.x / xmax*a2;
    double b = sqrt_safe(d - a * a)*b2;
    double ps = -M_PI_2 * a3;
    pVarTP.x += _v * atan2(a, b)+ps;

    //    if (pAffineTP.y > 0)
    if (pContext.random() < e)
      pVarTP.y += _v * log(xmax + sqrt_safe(xmax - f));
    else
      pVarTP.y -= _v * log(xmax + sqrt_safe(xmax - g));
    if (pContext.isPreserveZCoordinate()) {
  pVarTP.z += pAmount * pAffineTP.z;
}
  }
  @Override
  public String[] getParameterNames() {
    return paramNames;
  }

  @Override
  public Object[] getParameterValues() {
    return new Object[] { a1, a2, a3, b1, b2, c, d, e, f, g, h };
  }

  @Override
  public void setParameter(String pName, double pValue) {

    if (PARAM_A1.equalsIgnoreCase(pName)) {
        a1 = pValue;
      }
    else if (PARAM_A2.equalsIgnoreCase(pName)) {
        a2 = pValue;
      }    
    else if (PARAM_A3.equalsIgnoreCase(pName)) {
	      a3 = pValue;
      }
      else if (PARAM_B1.equalsIgnoreCase(pName)) {
        b1 = pValue;
      }
      else if (PARAM_B2.equalsIgnoreCase(pName)) {
          b2 = pValue;
        }
      else if (PARAM_C.equalsIgnoreCase(pName)) {
        c = pValue;
      }
      else if (PARAM_D.equalsIgnoreCase(pName)) {
        d = pValue;
      }
      else if (PARAM_E.equalsIgnoreCase(pName)) {
        e = pValue;
      }
      else if (PARAM_F.equalsIgnoreCase(pName)) {
        f = pValue;
      }
      else if (PARAM_G.equalsIgnoreCase(pName)) {
        g = pValue;
      }
      else if (PARAM_H.equalsIgnoreCase(pName)) {
        h = pValue;
      }
    else
      throw new IllegalArgumentException(pName);
  }
  @Override
  public String getName() {
    return "elliptic2";
  }

  private double _v;

  @Override
  public void init(FlameTransformationContext pContext, Layer pLayer, XForm pXForm, double pAmount) {
    _v = pAmount / (M_PI / h);
  }
}


Top
   
PostPosted: Fri Nov 30, 2018 2:58 pm 
Offline

Joined: Tue Mar 20, 2018 7:09 pm
Posts: 14
thanks for sharing


Top
   
PostPosted: Sun Jan 13, 2019 11:54 am 
Offline

Joined: Wed Jun 25, 2014 6:28 pm
Posts: 228
Location: Sardegna
Have you seen this: https://sourceforge.net/p/apo-plugins/c ... /bipolar.c

It also has some additional variables ;)

_________________
Plugin maker :)


Top
   
PostPosted: Tue Jan 15, 2019 1:53 pm 
Offline
User avatar

Joined: Sun May 31, 2015 2:39 pm
Posts: 568
No I haven't will take a look

Quote:
Have you seen this: https://sourceforge.net/p/apo-plugins/c ... /bipolar.c

It also has some additional variables ;)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited
Theme Created by HOLLYSMOKE
Theme updated to phpBB 3.1.6 by KamijouTouma
Theme Version is 3.1.6-ss2