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  * Fractal formula created by Buddhi
10  */
11 
12 #include "all_fractal_definitions.h"
13 
cFractalMandelbulb3()14 cFractalMandelbulb3::cFractalMandelbulb3() : cAbstractFractal()
15 {
16 	nameInComboBox = "Mandelbulb 3";
17 	internalName = "mandelbulb3";
18 	internalID = fractal::mandelbulb3;
19 	DEType = analyticDEType;
20 	DEFunctionType = logarithmicDEFunction;
21 	cpixelAddition = cpixelEnabledByDefault;
22 	defaultBailout = 10.0;
23 	DEAnalyticFunction = analyticFunctionLogarithmic;
24 	coloringFunction = coloringFunctionDefault;
25 }
26 
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)27 void cFractalMandelbulb3::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
28 {
29 	Q_UNUSED(fractal);
30 
31 	aux.DE = aux.DE * 2.0 * aux.r;
32 
33 	double temp, tempR;
34 
35 	double sign = 1.0;
36 	double sign2 = 1.0;
37 
38 	if (z.x < 0.0) sign2 = -1.0;
39 	tempR = sqrt(z.x * z.x + z.y * z.y); //+ 1e-061
40 	z *= 1.0 / tempR;
41 	temp = z.x * z.x - z.y * z.y;
42 	z.y = 2.0 * z.x * z.y;
43 	z.x = temp;
44 	z *= tempR;
45 
46 	if (z.x < 0.0) sign = -1.0;
47 	tempR = sqrt(z.x * z.x + z.z * z.z); //+ 1e-061
48 	z *= 1.0 / tempR;
49 	temp = z.x * z.x - z.z * z.z;
50 	z.z = 2.0 * z.x * z.z * sign2;
51 	z.x = temp * sign;
52 	z *= tempR;
53 
54 	z *= aux.r;
55 }
56