1 /**
2  * Mandelbulber v2, a 3D fractal generator  _%}}i*<.         ______
3  * Copyright (C) 2020 Mandelbulber Team   _>]|=||i=i<,      / ____/ __    __
4  *                                        \><||i|=>>%)     / /   __/ /___/ /_
5  * This file is part of Mandelbulber.     )<=i=]=|=i<>    / /__ /_  __/_  __/
6  * The project is licensed under GPLv3,   -<>>=|><|||`    \____/ /_/   /_/
7  * see also COPYING file in this folder.    ~+{i%+++
8  *
9  * spherical pwr fold
10  * This formula contains aux.color and analytic aux.DE
11  */
12 
13 #include "all_fractal_definitions.h"
14 
cFractalTransfSphericalPwrFold()15 cFractalTransfSphericalPwrFold::cFractalTransfSphericalPwrFold() : cAbstractFractal()
16 {
17 	nameInComboBox = "T>Spherical Pwr Fold";
18 	internalName = "transf_spherical_pwr_fold";
19 	internalID = fractal::transfSphericalPwrFold;
20 	DEType = analyticDEType;
21 	DEFunctionType = withoutDEFunction;
22 	cpixelAddition = cpixelDisabledByDefault;
23 	defaultBailout = 100.0;
24 	DEAnalyticFunction = analyticFunctionNone;
25 	coloringFunction = coloringFunctionDefault;
26 }
27 
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)28 void cFractalTransfSphericalPwrFold::FormulaCode(
29 	CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
30 {
31 	// if (z.x > -1e-21 && z.x < 1e-21) z.x = (z.x > 0) ? 1e-21 : -1e-21;
32 	// if (z.y > -1e-21 && z.y < 1e-21) z.y = (z.y > 0) ? 1e-21 : -1e-21;
33 	// if (z.z > -1e-21 && z.z < 1e-21) z.z = (z.z > 0) ? 1e-21 : -1e-21;
34 	double rr = pow(pow(z.x, fractal->transformCommon.pwr4) + pow(z.y, fractal->transformCommon.pwr4)
35 										+ pow(z.z, fractal->transformCommon.pwr4),
36 		fractal->transformCommon.pwr05);
37 
38 	// if (rr < 1e-21 && rr > -1e-21)
39 	//	rr = (rr > 0) ? 1e-21 : -1e-21;
40 	if (rr < fractal->mandelbox.mR2)
41 	{
42 		z *= fractal->mandelbox.mboxFactor1;
43 		aux.DE *= fractal->mandelbox.mboxFactor1;
44 		if (fractal->foldColor.auxColorEnabledFalse)
45 		{
46 			aux.color += fractal->mandelbox.color.factorSp1;
47 		}
48 	}
49 	else if (rr < fractal->mandelbox.fR2)
50 	{
51 		double tglad_factor2 = fractal->mandelbox.fR2 / rr;
52 		z *= tglad_factor2;
53 		aux.DE *= tglad_factor2;
54 		if (fractal->foldColor.auxColorEnabledFalse)
55 		{
56 			aux.color += fractal->mandelbox.color.factorSp2;
57 		}
58 	}
59 }
60