jwildfire.org

The official JWildfire forum
It is currently Mon May 25, 2020 6:50 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
 Post subject: sigmoid, octapol
PostPosted: Tue Jul 11, 2017 9:30 pm 
Offline

Joined: Wed Jun 25, 2014 6:28 pm
Posts: 230
Location: Sardegna
Also this one is missing! :o
Just c code for now as a reminder. I think the plugin is by Xyrus itself. Taken from Apo7x source.
Code:
/*
    Apophysis Plugin

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

typedef struct
{
	double sigmoid_shiftx;
	double sigmoid_shifty;
	double sx, sy, ax, ay, vv;
} Variables;

#include "apoplugin.h"

APO_PLUGIN("sigmoid");

APO_VARIABLES(
	VAR_REAL(sigmoid_shiftx, 1.0),
	VAR_REAL(sigmoid_shifty, 1.0)
);

int PluginVarPrepare(Variation* vp)
{
	VAR(ax) = 1.0; VAR(ay) = 1.0;
	VAR(sx) = VAR(sigmoid_shiftx); VAR(sy) = VAR(sigmoid_shifty);
    if (VAR(sx) < 1 && VAR(sx) > -1) {
       if (VAR(sx) == 0) {
          VAR(sx) = EPS; VAR(ax) = 1.0;
       } else {
         VAR(ax) = (VAR(sx) < 0 ? -1 : 1);
         VAR(sx) = 1 / VAR(sx);
       }
    }
    if (VAR(sy) < 1 && VAR(sy) > -1) {
       if (VAR(sy) == 0) {
          VAR(sy) = EPS; VAR(ay) = 1.0;
       } else {
         VAR(ay) = (VAR(sy) < 0 ? -1 : 1);
         VAR(sy) = 1 / VAR(sy);
       }
    }
    
	VAR(sx) *= -5;
	VAR(sy) *= -5;
	
	VAR(vv) = fabs(VVAR);
    return TRUE;
}

int PluginVarCalc(Variation* vp)
{
    double c0 = VAR(ax) / (1.0 + exp(VAR(sx) * FTx));
    double c1 = VAR(ay) / (1.0 + exp(VAR(sy) * FTy));
    double x = (2 * (c0 - 0.5));
    double y = (2 * (c1 - 0.5));
    
    FPx += VAR(vv) * x;
    FPy += VAR(vv) * y;

    return TRUE;
}
Sample flame: :D

http://prelkia.deviantart.com/art/Sigmo ... -140149411

Octapol seems much more complicated.
Code:
/*
    Octapol plugin for Apophysis
    Written by Georg K. (http://xyrus02.deviantart.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

typedef struct
{
	double x;
	double y;
} double2;

#define DOUBLE2(x,y) { x, y }
#define DENOM_SQRT2 0.707106781

typedef struct
{
	double rad, s, t, a;
	double ax, ay, bx, by, cx, cy, 
		   dx, dy, ex, ey, fx, fy,
		   gx, gy, hx, hy, ix, iy,
		   jx, jy, kx, ky, lx, ly;
	
	double octapol_polarweight;
	double octapol_radius;
	double octapol_s;
	double octapol_t;
} Variables;

#include "apoplugin.h"

APO_PLUGIN("octapol");

APO_VARIABLES(
	VAR_REAL(octapol_polarweight, 0.0),
	VAR_REAL(octapol_radius, 1.0),
	VAR_REAL(octapol_s, 0.5),
	VAR_REAL(octapol_t, 0.5)
);

int PluginVarPrepare(Variation* vp)
{
	VAR(s) = fabs(VAR(octapol_s));
	VAR(t) = fabs(VAR(octapol_t));
	VAR(a) = VAR(s) * 0.5 + VAR(t);
	
	VAR(rad) = DENOM_SQRT2 * VAR(s) * fabs(VAR(octapol_radius));
	
	VAR(ax) = -0.5 * VAR(s); VAR(ay) = 0.5 * VAR(s) + VAR(t);	
	VAR(bx) = 0.5 * VAR(s); VAR(by) = 0.5 * VAR(s) + VAR(t);
	VAR(cx) = VAR(t); VAR(cy) = 0.5 * VAR(s);
	VAR(dx) = VAR(t); VAR(dy) = -0.5 * VAR(s);
	VAR(ex) = 0.5 * VAR(s); VAR(ey) = -0.5 * VAR(s) - VAR(t);
	VAR(fx) = -0.5 * VAR(s); VAR(fy) = -0.5 * VAR(s) - VAR(t);
	VAR(gx) = -VAR(t); VAR(gy) = -0.5 * VAR(s);
	VAR(hx) = -VAR(t); VAR(hy) = 0.5 * VAR(s);
	VAR(ix) = -0.5 * VAR(s); VAR(iy) = 0.5 * VAR(s);
	VAR(jx) = 0.5 * VAR(s); VAR(jy) = 0.5 * VAR(s);
	VAR(kx) = -0.5 * VAR(s); VAR(ky) = -0.5 * VAR(s);
	VAR(lx) = 0.5 * VAR(s); VAR(ly) = -0.5 * VAR(s);
	
    return TRUE; 
}

inline double dot(double2 a, double2 b) {
	return a.x * b.x + a.y * b.y;	
}
inline double lerp(double a, double b, double p) {
	return a + p * (b - a);	
}
inline int hits_rect(double2 tl, double2 br, double2 p) {
	return (p.x >= tl.x && p.y >= tl.y && p.x <= br.x && p.y <= br.y);
}
inline int hits_triangle(double2 a, double2 b, double2 c, double2 p, double* u, double* v) {
	double2 v0 = DOUBLE2(c.x - a.x, c.y - a.y);
	double2 v1 = DOUBLE2(b.x - a.x, b.y - a.y);
	double2 v2 = DOUBLE2(p.x - a.x, p.y - a.y);
	
	double d00 = dot(v0, v0);
	double d01 = dot(v0, v1);
	double d02 = dot(v0, v2);
	double d11 = dot(v1, v1);
	double d12 = dot(v1, v2);
	
	double denom = (d00 * d11 - d01 * d01);
	if (denom != 0) {
		*u = (d11 * d02 - d01 * d12) / denom;
		*v = (d00 * d12 - d01 * d02) / denom;
	} else {
		*u = *v = 0;	
	}
	
	return ((*u + *v) < 1.0) && (*u > 0) && (*v > 0);
}
inline int hits_square_around_origin(double a, double2 p) {
	return (fabs(p.x) <= a && fabs(p.y) <= a);
}
inline int hits_circle_around_origin(double radius, double2 p, double* r) {
	if (radius == 0.0) return TRUE;
	*r = sqrt(sqr(p.x) + sqr(p.y));
	return (*r <= radius);
}

int PluginVarCalc(Variation* vp)
{
	double x = FTx * 0.15, y = FTy * 0.15, z = FTz, r = 0, u = 0, v = 0, x2 = 0, y2 = 0;
	double2 XY = DOUBLE2(x, y);
	
	double2 A = DOUBLE2(VAR(ax), VAR(ay)), B = DOUBLE2(VAR(bx), VAR(by)), C = DOUBLE2(VAR(cx), VAR(cy)),
			D = DOUBLE2(VAR(dx), VAR(dy)), E = DOUBLE2(VAR(ex), VAR(ey)), F = DOUBLE2(VAR(fx), VAR(fy)),
			G = DOUBLE2(VAR(gx), VAR(gy)), H = DOUBLE2(VAR(hx), VAR(hy)), I = DOUBLE2(VAR(ix), VAR(iy)),
			J = DOUBLE2(VAR(jx), VAR(jy)), K = DOUBLE2(VAR(kx), VAR(ky)), L = DOUBLE2(VAR(lx), VAR(ly));
	
	if ((VAR(rad) > 0) && hits_circle_around_origin(VAR(rad), XY, &r)) {
		double rd = log(sqr(r / VAR(rad)));
		double phi = atan2(y, x);
		FPx += VVAR * lerp(x, phi, rd * VAR(octapol_polarweight)); 
		FPy += VVAR * lerp(y, r, rd * VAR(octapol_polarweight));
	} else if (hits_square_around_origin(VAR(a), XY)) {
		if (hits_rect(H, K, XY) || hits_rect(J, D, XY) ||
		    hits_rect(A, J, XY) || hits_rect(K, E, XY) ||
		    hits_triangle(I, A, H, XY, &u, &v) || 
			hits_triangle(J, B, C, XY, &u, &v) ||
		    hits_triangle(L, D, E, XY, &u, &v) || 
			hits_triangle(K, F, G, XY, &u, &v)) {
			FPx += VVAR * x; FPy += VVAR * y;
		} else FPx = FPy = 0;
	} else FPx = FPy = 0;
	
	FPx += VVAR * x; 
	FPy += VVAR * y;
	FPz += VVAR * z;
    return TRUE;
}

_________________
Plugin maker :)


Top
   
 Post subject: Re: sigmoid, octapol
PostPosted: Thu Jul 13, 2017 7:40 pm 
Offline
User avatar

Joined: Sun May 31, 2015 2:39 pm
Posts: 642
Here is my try at sigmoid
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.*;
import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;

public class SigmoidFunc extends VariationFunc {
  private static final long serialVersionUID = 1L;
  
  private static final String PARAM_SHIFTX = "shiftx";
  private static final String PARAM_SHIFTY = "shifty";
  private static final String[] paramNames = { PARAM_SHIFTX, PARAM_SHIFTY };

  private double shiftx = 1.0;
  private double shifty = 1.0;

  @Override
  public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
   // author Xyrus. Implemented by Brad Stefanov
	  double ax = 1.0; 
	  double ay = 1.0;
	  double sx = shiftx; 
	  double sy = shifty;
	    if (sx < 1 && sx > -1) {
	       if (sx == 0) {
	          sx = EPSILON; ax = 1.0;
	       } else {
	         ax = (sx < 0 ? -1 : 1);
	         sx = 1 / sx;
	       }
	    }
	    if (sy < 1 && sy > -1) {
	       if (sy == 0) {
	          sy = EPSILON; ay = 1.0;
	       } else {
	         ay = (sy < 0 ? -1 : 1);
	         sy = 1 / sy;
	       }
	    }
	    
	    sx *= -5;
	    sy *= -5;
	   
	   double vv = fabs(pAmount);

  double c0 = ax / (1.0 + exp(sx *  pAffineTP.x ));
  double c1 = ay / (1.0 + exp(sy *  pAffineTP.y));
  double x = (2 * (c0 - 0.5));
  double y = (2 * (c1 - 0.5));
  
  pVarTP.x += vv * x;
  pVarTP.y += vv * y;
}
  @Override
  public String[] getParameterNames() {
    return paramNames;
  }

  @Override
  public Object[] getParameterValues() {
    return new Object[] { shiftx, shifty };
  }

  @Override
  public void setParameter(String pName, double pValue) {
    if (PARAM_SHIFTX.equalsIgnoreCase(pName))
    	shiftx =  pValue;
    else if (PARAM_SHIFTY.equalsIgnoreCase(pName))
    	shifty = pValue;
    else
      throw new IllegalArgumentException(pName);
  }




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

}
compare to sample flame
Image


Top
   
 Post subject: Re: sigmoid, octapol
PostPosted: Fri Jul 14, 2017 4:10 am 
Offline
User avatar

Joined: Mon Jun 08, 2015 4:40 am
Posts: 308
You are on fire, Brad. Thanks for this and all the others. My custom variations folder is getting VERY full. LOL


Top
   
 Post subject: Re: sigmoid, octapol
PostPosted: Sun Jul 16, 2017 10:21 pm 
Offline

Joined: Wed Jun 25, 2014 6:28 pm
Posts: 230
Location: Sardegna
Great! Thanks :ugeek:

_________________
Plugin maker :)


Top
   
 Post subject: Re: sigmoid, octapol
PostPosted: Mon Jul 17, 2017 2:01 am 
Offline
User avatar

Joined: Sun May 31, 2015 2:39 pm
Posts: 642
Quote:
Great! Thanks :ugeek:
your welcome but Octapol is waaaay beyond me lol


Top
   
 Post subject: Re: sigmoid, octapol
PostPosted: Sun Dec 15, 2019 11:12 pm 
Offline
Site Admin
User avatar

Joined: Wed May 15, 2013 10:28 pm
Posts: 1434
Octapol coming with next release


Top
   
 Post subject: Re: sigmoid
PostPosted: Fri Apr 03, 2020 10:23 pm 
Offline
User avatar

Joined: Mon Jun 03, 2013 7:44 am
Posts: 214
Your sigmoid for JWF looks awesome Brad! Thanks!

_________________
Fractal artwork: http://ablipintime.deviantart.com


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

All times are UTC+01:00


Who is online

Users browsing this forum: Bing [Bot] and 12 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:  
cron
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