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 * http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
10 */
11
12 #include "all_fractal_definitions.h"
13
cFractalTransfDIFSTorus()14 cFractalTransfDIFSTorus::cFractalTransfDIFSTorus() : cAbstractFractal()
15 {
16 nameInComboBox = "T>DIFS Torus";
17 internalName = "transf_difs_torus";
18 internalID = fractal::transfDIFSTorus;
19 DEType = analyticDEType;
20 DEFunctionType = customDEFunction;
21 cpixelAddition = cpixelDisabledByDefault;
22 defaultBailout = 100.0;
23 DEAnalyticFunction = analyticFunctionCustomDE;
24 coloringFunction = coloringFunctionDefault;
25 }
26
FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)27 void cFractalTransfDIFSTorus::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux)
28 {
29 CVector4 zc = z;
30 double torD;
31 // swap axis
32 if (fractal->transformCommon.functionEnabledSwFalse)
33 swap(zc.x, zc.z);
34 if (fractal->transformCommon.functionEnabledSFalse)
35 swap(zc.y, zc.z);
36
37 double T1 = sqrt(zc.y * zc.y + zc.x * zc.x) - fractal->transformCommon.offsetT1;
38
39 if (!fractal->transformCommon.functionEnabledJFalse)
40 torD = sqrt(T1 * T1 + zc.z * zc.z) - fractal->transformCommon.offset05;
41 else
42 torD = max(fabs(T1), fabs(zc.z)) - fractal->transformCommon.offset05;
43
44 aux.dist = min(aux.dist, torD / (aux.DE + 1.0));
45 }
46