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 * 3D Version of the 2D Eye Fractal created by biberino, modified mclarekin
10 */
11
12 #include "all_fractal_definitions.h"
13
cFractalMandelbulbEye()14 cFractalMandelbulbEye::cFractalMandelbulbEye() : cAbstractFractal()
15 {
16 nameInComboBox = "Mandelbulb - Eye";
17 internalName = "mandelbulb_eye";
18 internalID = fractal::mandelbulbEye;
19 DEType = analyticDEType;
20 DEFunctionType = logarithmicDEFunction;
21 cpixelAddition = cpixelEnabledByDefault;
22 defaultBailout = 2.0;
23 DEAnalyticFunction = analyticFunctionLogarithmic;
24 coloringFunction = coloringFunctionDefault;
25 }
26
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)27 void cFractalMandelbulbEye::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
28 {
29 aux.DE = aux.DE * 2.0 * aux.r;
30
31 // pre abs
32 if (fractal->buffalo.preabsx) z.x = fabs(z.x);
33 if (fractal->buffalo.preabsy) z.y = fabs(z.y);
34 if (fractal->buffalo.preabsz) z.z = fabs(z.z);
35
36 // bulb
37 CVector4 zz = z * z;
38 double rr = zz.x + zz.y + zz.z;
39 double temp = sqrt(zz.x + zz.y);
40 double theta1 = atan2(temp, z.z) * fractal->transformCommon.scaleB1;
41 double theta2 = atan2(temp, -z.z) * fractal->transformCommon.scaleC1;
42 temp = theta1 + theta2;
43
44 double phi1 = atan2(z.y, z.x);
45 double phi2 = 0.0;
46 if (!fractal->transformCommon.functionEnabledFalse)
47 phi2 = atan2(-z.y, z.x);
48 else
49 phi2 = M_PI - phi1;
50 phi1 *= fractal->transformCommon.scale1;
51 phi1 += phi2;
52
53 temp = rr * sin(theta1 + theta2);
54 z.x = temp * cos(phi1);
55 z.y = temp * sin(phi1);
56 z.z = rr * cos(theta1 + theta2);
57
58 // post abs
59 z.x = fractal->buffalo.absx ? fabs(z.x) : z.x;
60 z.y = fractal->buffalo.absy ? fabs(z.y) : z.y;
61 z.z = fractal->buffalo.absz ? fabs(z.z) : z.z;
62
63 // offset
64 z += fractal->transformCommon.additionConstantA000;
65
66 // analyticDE controls
67 if (fractal->analyticDE.enabledFalse)
68 aux.DE = aux.DE * fractal->analyticDE.scale1 + fractal->analyticDE.offset1;
69 }
70