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 * Blockify 10 * based on a block of Fragmentarium code, from Adam Nixon 11 * analytic aux.DE 12 */ 13 14 #include "all_fractal_definitions.h" 15 cFractalTransfBlockify()16cFractalTransfBlockify::cFractalTransfBlockify() : cAbstractFractal() 17 { 18 nameInComboBox = "T>Blockify"; 19 internalName = "transf_blockify"; 20 internalID = fractal::transfBlockify; 21 DEType = analyticDEType; 22 DEFunctionType = withoutDEFunction; 23 cpixelAddition = cpixelDisabledByDefault; 24 defaultBailout = 100.0; 25 DEAnalyticFunction = analyticFunctionNone; 26 coloringFunction = coloringFunctionDefault; 27 } 28 FormulaCode(CVector4 & z,const sFractal * fractal,sExtendedAux & aux)29void cFractalTransfBlockify::FormulaCode(CVector4 &z, const sFractal *fractal, sExtendedAux &aux) 30 { 31 double master = fractal->transformCommon.scale / 100.0; 32 CVector4 bSize = fractal->transformCommon.constantMultiplier111 * master; 33 34 if (!fractal->transformCommon.functionEnabledFalse) 35 { 36 if (!fractal->transformCommon.functionEnabledDFalse) 37 { 38 if (fractal->transformCommon.functionEnabledCx) z.x = (floor(z.x / bSize.x) + 0.5) * bSize.x; 39 if (fractal->transformCommon.functionEnabledCy) z.y = (floor(z.y / bSize.y) + 0.5) * bSize.y; 40 if (fractal->transformCommon.functionEnabledCz) z.z = (floor(z.z / bSize.z) + 0.5) * bSize.z; 41 } 42 else // normalize 43 { 44 double rNorm = z.Length(); //z.Dot(z); 45 z /= rNorm; 46 if (fractal->transformCommon.functionEnabledCx) z.x = (floor(z.x / bSize.x) + 0.5) * bSize.x; 47 if (fractal->transformCommon.functionEnabledCy) z.y = (floor(z.y / bSize.y) + 0.5) * bSize.y; 48 if (fractal->transformCommon.functionEnabledCz) z.z = (floor(z.z / bSize.z) + 0.5) * bSize.z; 49 z *= rNorm; 50 } 51 } 52 else // radial 53 { 54 double rr = z.Dot(z); 55 if (fractal->transformCommon.functionEnabledRFalse) rr = sqrt(rr); // z.Length(); 56 if (fractal->transformCommon.functionEnabledBxFalse) rr = z.x * z.x + z.y * z.y; 57 if (fractal->transformCommon.functionEnabledByFalse) rr = z.y * z.y + z.z * z.z; 58 if (fractal->transformCommon.functionEnabledBzFalse) rr = z.z * z.z + z.x * z.x; 59 z /= rr; 60 rr = floor(rr / master) * master; 61 z *= rr; 62 } 63 64 // post scale 65 z *= fractal->transformCommon.scale1; 66 aux.DE = aux.DE * fractal->transformCommon.scale1 * fractal->analyticDE.scale1 67 + fractal->analyticDE.offset0; 68 69 } 70