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 * Menger Smooth Mod1, based on :
10 * http://www.fractalforums.com/fragmentarium/help-t22583/
11 */
12
13 #include "all_fractal_definitions.h"
14
cFractalMengerSmoothMod1()15 cFractalMengerSmoothMod1::cFractalMengerSmoothMod1() : cAbstractFractal()
16 {
17 nameInComboBox = "Menger - Smooth Mod1";
18 internalName = "menger_smooth_mod1";
19 internalID = fractal::mengerSmoothMod1;
20 DEType = analyticDEType;
21 DEFunctionType = linearDEFunction;
22 cpixelAddition = cpixelDisabledByDefault;
23 defaultBailout = 10.0;
24 DEAnalyticFunction = analyticFunctionIFS;
25 coloringFunction = coloringFunctionDefault;
26 }
27
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)28 void cFractalMengerSmoothMod1::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
29 {
30 if (fractal->transformCommon.functionEnabled)
31 {
32 z = CVector4(sqrt(z.x * z.x + fractal->transformCommon.offset0),
33 sqrt(z.y * z.y + fractal->transformCommon.offset0),
34 sqrt(z.z * z.z + fractal->transformCommon.offset0), z.w);
35 }
36 if (fractal->transformCommon.functionEnabledFFalse)
37 {
38 z = fabs(z);
39 double s = fractal->transformCommon.offset;
40 z += CVector4(s, s, s, 0.0);
41 }
42
43 double t;
44 double ScaleP5 = fractal->transformCommon.scale05;
45 CVector4 OffsetC = fractal->transformCommon.constantMultiplier221;
46 double OffsetS = fractal->transformCommon.offset0005;
47
48 t = z.x - z.y;
49 t = ScaleP5 * (t - sqrt(t * t + OffsetS * fractal->transformCommon.constantMultiplier111.x));
50 z.x = z.x - t;
51 z.y = z.y + t;
52
53 t = z.x - z.z;
54 t = ScaleP5 * (t - sqrt(t * t + OffsetS * fractal->transformCommon.constantMultiplier111.y));
55 z.x = z.x - t;
56 z.z = z.z + t;
57
58 t = z.y - z.z;
59 t = ScaleP5 * (t - sqrt(t * t + OffsetS * fractal->transformCommon.constantMultiplier111.z));
60 z.y = z.y - t;
61 z.z = z.z + t;
62
63 z.z = z.z - OffsetC.z / 3.0;
64 z.z = -sqrt(z.z * z.z + OffsetS);
65 z.z = z.z + OffsetC.z / 3.0;
66
67 z.x = fractal->transformCommon.scale3 * z.x - OffsetC.x;
68 z.y = fractal->transformCommon.scale3 * z.y - OffsetC.y;
69 z.z = fractal->transformCommon.scale3 * z.z;
70
71 aux.DE *= fractal->transformCommon.scale3;
72
73 if (fractal->transformCommon.rotationEnabled && aux.i >= fractal->transformCommon.startIterationsR
74 && aux.i < fractal->transformCommon.stopIterationsR)
75 {
76 z = fractal->transformCommon.rotationMatrix.RotateVector(z);
77 }
78
79 if (fractal->transformCommon.functionEnabledxFalse
80 && aux.i >= fractal->transformCommon.startIterationsA
81 && aux.i < fractal->transformCommon.stopIterationsA) // box offset
82 {
83 z.x = sign(z.x) * fractal->transformCommon.additionConstantA000.x + z.x;
84 z.y = sign(z.y) * fractal->transformCommon.additionConstantA000.y + z.y;
85 z.z = sign(z.z) * fractal->transformCommon.additionConstantA000.z + z.z;
86 }
87
88 if (fractal->transformCommon.functionEnabledzFalse)
89 {
90 CVector4 zA = (aux.i == fractal->transformCommon.intA) ? z : CVector4();
91 CVector4 zB = (aux.i == fractal->transformCommon.intB) ? z : CVector4();
92
93 z = (z * fractal->transformCommon.scale1) + (zA * fractal->transformCommon.offsetA0)
94 + (zB * fractal->transformCommon.offsetB0);
95 aux.DE *= fractal->transformCommon.scale1;
96 }
97 }
98