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 * MsltoeSym4Mod Based on the formula from Mandelbulb3D
10 * @reference http://www.fractalforums.com/theory/choosing-the-squaring-formula-by-location/15/
11 * This formula contains aux.color
12 */
13
14 #include "all_fractal_definitions.h"
15
cFractalMsltoeSym4Mod()16 cFractalMsltoeSym4Mod::cFractalMsltoeSym4Mod() : cAbstractFractal()
17 {
18 nameInComboBox = "Msltoe - Sym4 Mod";
19 internalName = "msltoe_sym4_mod";
20 internalID = fractal::msltoeSym4Mod;
21 DEType = analyticDEType;
22 DEFunctionType = logarithmicDEFunction;
23 cpixelAddition = cpixelEnabledByDefault;
24 defaultBailout = 10.0;
25 DEAnalyticFunction = analyticFunctionLogarithmic;
26 coloringFunction = coloringFunctionDefault;
27 }
28
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)29 void cFractalMsltoeSym4Mod::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
30 {
31 CVector4 c = aux.const_c;
32 CVector4 oldZ = z;
33 aux.DE = aux.DE * 2.0 * aux.r;
34
35 if (fabs(z.x) < fabs(z.z) * fractal->transformCommon.constantMultiplier111.x) swap(z.x, z.z);
36 if (fabs(z.x) < fabs(z.y) * fractal->transformCommon.constantMultiplier111.y) swap(z.x, z.y);
37 if (fabs(z.y) < fabs(z.z) * fractal->transformCommon.constantMultiplier111.z) swap(z.y, z.z);
38
39 if (fractal->foldColor.auxColorEnabledFalse)
40 {
41 if (z.x != oldZ.x) aux.color += fractal->mandelbox.color.factor.x;
42 if (z.y != oldZ.y) aux.color += fractal->mandelbox.color.factor.y;
43 if (z.z != oldZ.z) aux.color += fractal->mandelbox.color.factor.z;
44 }
45 if (z.x * z.z < 0.0) z.z = -z.z;
46 if (z.x * z.y < 0.0) z.y = -z.y;
47
48 z *= fractal->transformCommon.scale3D111;
49 aux.DE *= z.Length() / aux.r;
50
51 CVector4 temp = z;
52 temp.x = z.x * z.x - z.y * z.y - z.z * z.z;
53 temp.y = 2.0 * z.x * z.y;
54 temp.z = 2.0 * z.x * z.z;
55
56 z = temp + fractal->transformCommon.additionConstant000;
57
58 if (fractal->transformCommon.rotationEnabled)
59 {
60 z = fractal->transformCommon.rotationMatrix.RotateVector(z);
61 }
62
63 double lengthTempZ = -z.Length();
64 // if (lengthTempZ > -1e-21)
65 // lengthTempZ = -1e-21; // z is neg.)
66 z *= 1.0 + fractal->transformCommon.offset / lengthTempZ;
67 z *= fractal->transformCommon.scale1;
68 aux.DE *= fabs(fractal->transformCommon.scale1);
69
70 if (fractal->transformCommon.addCpixelEnabledFalse)
71 {
72 CVector4 tempFAB = c;
73 if (fractal->transformCommon.functionEnabledx) tempFAB.x = fabs(tempFAB.x);
74 if (fractal->transformCommon.functionEnabledy) tempFAB.y = fabs(tempFAB.y);
75 if (fractal->transformCommon.functionEnabledz) tempFAB.z = fabs(tempFAB.z);
76
77 tempFAB *= fractal->transformCommon.constantMultiplier000;
78 z.x += sign(z.x) * tempFAB.x;
79 z.y += sign(z.y) * tempFAB.y;
80 z.z += sign(z.z) * tempFAB.z;
81 }
82 }
83