jwildfire.org

The official JWildfire forum
It is currently Sat Jul 20, 2019 2:22 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Juliascope3Db
PostPosted: Thu May 02, 2019 1:29 pm 
Offline
User avatar

Joined: Sun May 31, 2015 2:39 pm
Posts: 599
// 3D version of juliascope, with added variables by Brad Stefanov.
// mode (0,1) type (0,1) wave1 and wave 2 only work with mode = 1

Make sure you also work on the yz/zx planes to get full effect.

Example image

Image

Custom Code
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 org.jwildfire.base.Tools;
import org.jwildfire.create.tina.base.Layer;
import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;

import static org.jwildfire.base.mathlib.MathLib.*;

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

	private static final String PARAM_POWER = "power";
	private static final String PARAM_ZBIST = "dist";
	private static final String PARAM_TYPE = "type";

	private static final String PARAM_WARP = "warp";
	private static final String PARAM_ZA = "za";
	private static final String PARAM_ZB = "zb";
	private static final String PARAM_ZAMOUNT = "zamount";
	private static final String PARAM_ZDIST = "zdist";
	private static final String PARAM_MODE = "mode";
	private static final String PARAM_WAVE1 = "wave1";
	private static final String PARAM_WAVE2 = "wave2";

	private static final String[] paramNames = { PARAM_POWER, PARAM_ZBIST, PARAM_TYPE, PARAM_WARP, PARAM_ZA, PARAM_ZB,
			PARAM_ZAMOUNT, PARAM_ZDIST, PARAM_MODE, PARAM_WAVE1, PARAM_WAVE2 };

	private double power = genRandomPower();
	private double dist = 1;
	private int type = 0;
	private double warp = 0.0;
	private double za = 1.0;
	private double zb = 1.0;
	private double zamount = 1.0;
	private double zdist = 1.0;
	private int mode = 0;
	private double wave1 = 1.0;
	private double wave2 = 1.0;

	@Override
	public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP,
			double pAmount) {
		// if (power == 2)
		// transformPower2(pContext, pXForm, pAffineTP, pVarTP, pAmount);
		// else if (power == -2)
		// transformPowerMinus2(pContext, pXForm, pAffineTP, pVarTP, pAmount);
		// else if (power == 1)
		// transformPower1(pContext, pXForm, pAffineTP, pVarTP, pAmount);
		// else if (power == -1)
		// transformPowerMinus1(pContext, pXForm, pAffineTP, pVarTP, pAmount);
		// else
		transformFunction(pContext, pXForm, pAffineTP, pVarTP, pAmount);
	}
    // 3D version of juliascope, with added variables by Brad Stefanov. 
    // mode (0,1) type (0,1)  wave1 and wave 2 only work with mode = 1
	public void transformFunction(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP,
			XYZPoint pVarTP, double pAmount) {

		double z = pAffineTP.z / absPower + warp;
		double r2d = pAffineTP.x * pAffineTP.x * za + pAffineTP.y * pAffineTP.y * zb;
		double rz = pAmount * zamount * pow(r2d + z * z, cPower * zdist);

		int rnd = pContext.random(absPower);
		double a;
		if ((rnd & 1) == 0)
			a = (2 * M_PI * rnd + atan2(pAffineTP.y, pAffineTP.x)) / power;
		else
			a = (2 * M_PI * rnd - atan2(pAffineTP.y, pAffineTP.x)) / power;

		double r;
		if (type != 0) {
			r = pAmount * pow(sqr(pAffineTP.x) + sqr(pAffineTP.y) + sqr(pAffineTP.z), cPower);
		} else {
			r = pAmount * pow(sqr(pAffineTP.x) + sqr(pAffineTP.y), cPower);
		}
		double cosa = cos(a);
		double sina = sin(a);

		pVarTP.x = pVarTP.x + r * cosa;
		pVarTP.y = pVarTP.y + r * sina;
		if (mode != 0) {
			double sincosa = sin(wave1) * cos(wave2);
			pVarTP.z += rz * z * sincosa;
		} else {
			pVarTP.z += rz * z;
		}
		// pVarTP.z += rz * z * sincosa;

	}

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

	@Override
	public Object[] getParameterValues() {
		return new Object[] { power, dist, type, warp, za, zb, zamount, zdist, mode, wave1, wave2 };
	}

	@Override
	public void setParameter(String pName, double pValue) {
		if (PARAM_POWER.equalsIgnoreCase(pName))
			power = pValue;
		else if (PARAM_ZBIST.equalsIgnoreCase(pName))
			dist = pValue;
		else if (PARAM_TYPE.equalsIgnoreCase(pName))
			type = (int) limitVal(pValue, 0, 1);
		else if (PARAM_WARP.equalsIgnoreCase(pName)) {
			warp = pValue;
		} else if (PARAM_ZA.equalsIgnoreCase(pName)) {
			za = pValue;
		} else if (PARAM_ZB.equalsIgnoreCase(pName)) {
			zb = pValue;
		} else if (PARAM_ZAMOUNT.equalsIgnoreCase(pName)) {
			zamount = pValue;
		} else if (PARAM_ZDIST.equalsIgnoreCase(pName)) {
			zdist = pValue;
		} else if (PARAM_MODE.equalsIgnoreCase(pName))
			mode = (int) limitVal(pValue, 0, 1);
		else if (PARAM_WAVE1.equalsIgnoreCase(pName)) {
			wave1 = pValue;
		} else if (PARAM_WAVE2.equalsIgnoreCase(pName)) {
			wave2 = pValue;
		} else {
			System.out.println("pName not recognized: " + pName);
			throw new IllegalArgumentException(pName);
		}
	}

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

	private int genRandomPower() {
		int res = (int) (Math.random() * 5.0 + 2.5);
		return Math.random() < 0.5 ? res : -res;
	}

	private int absPower;
	private double cPower;

	@Override
	public void init(FlameTransformationContext pContext, Layer pLayer, XForm pXForm, double pAmount) {
		absPower = iabs(Tools.FTOI(power));
		cPower = dist / power * 0.5;
	}

}
Example flame

https://pastebin.com/cpMnEjdv


You do not have the required permissions to view the files attached to this post.


Top
   
 Post subject: Re: Juliascope3Db
PostPosted: Mon Jul 01, 2019 12:50 pm 
Offline
User avatar

Joined: Mon Jun 08, 2015 4:40 am
Posts: 298
Thanks!


Top
   
 Post subject: Re: Juliascope3Db
PostPosted: Mon Jul 08, 2019 8:02 pm 
Offline

Joined: Fri Jun 21, 2013 6:23 pm
Posts: 6
Thanks Brad!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 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:  
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