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 * CollatzIteration formula
10 * @reference https://mathr.co.uk/blog/2016-04-10_collatz_fractal.html
11 * https://en.wikipedia.org/wiki/Collatz_conjecture#Iterating_on_real_or_complex_numbers
12 */
13
14 #include "all_fractal_definitions.h"
15
cFractalCollatz()16 cFractalCollatz::cFractalCollatz() : cAbstractFractal()
17 {
18 nameInComboBox = "Collatz";
19 internalName = "collatz";
20 internalID = fractal::collatz;
21 DEType = analyticDEType;
22 DEFunctionType = linearDEFunction;
23 cpixelAddition = cpixelDisabledByDefault;
24 defaultBailout = 10.0;
25 DEAnalyticFunction = analyticFunctionIFS;
26 coloringFunction = coloringFunctionIFS;
27 }
28
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)29 void cFractalCollatz::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
30 {
31 Q_UNUSED(fractal);
32
33 CVector4 xV = CVector4(1.0, 1.0, 1.0, 0.0);
34 CVector4 temp = xV + z * 2.0;
35 temp *= z.RotateAroundVectorByAngle(xV.GetXYZ(), M_PI);
36 z = xV + z * 4.0 - temp;
37 z /= 4.0;
38 aux.DE = aux.DE * 4.0 + 1.0;
39 }
40