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 * spherical fold Cuboid 10 * This has a box shape MinR2 condition 11 * This formula contains aux.color 12 */ 13 14 #include "all_fractal_definitions.h" 15 cFractalTransfSphericalFoldCuboid()16cFractalTransfSphericalFoldCuboid::cFractalTransfSphericalFoldCuboid() : cAbstractFractal() 17 { 18 nameInComboBox = "T>Spherical Fold Cuboid"; 19 internalName = "transf_spherical_fold_cuboid"; 20 internalID = fractal::transfSphericalFoldCuboid; 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 cFractalTransfSphericalFoldCuboid::FormulaCode( 30 CVector4 &z, const sFractal *fractal, sExtendedAux &aux) 31 { 32 CVector4 temp3; 33 CVector4 R2; 34 double minR2 = fractal->transformCommon.minR2p25; 35 CVector4 limitMinR2 = fractal->transformCommon.scaleP222; 36 double m = fractal->transformCommon.scale; 37 38 double rr = z.Dot(z); 39 z += fractal->transformCommon.offset000; 40 41 if (aux.i >= fractal->transformCommon.startIterationsA 42 && aux.i < fractal->transformCommon.stopIterationsA) 43 { 44 if (fractal->transformCommon.functionEnabledAxFalse) 45 temp3 = z * z; 46 else 47 temp3 = fabs(z); 48 49 if (temp3.x < limitMinR2.x && temp3.y < limitMinR2.y && temp3.z < limitMinR2.z) 50 { // if inside cuboid 51 R2.x = limitMinR2.x / temp3.x; 52 R2.y = limitMinR2.y / temp3.y; 53 R2.z = limitMinR2.z / temp3.z; 54 double First = min(R2.x, min(R2.y, R2.z)); 55 minR2 = rr * First; 56 57 if (fractal->transformCommon.functionEnabled && minR2 > fractal->transformCommon.maxR2d1) 58 { // stop overlapping potential 59 minR2 = fractal->transformCommon.maxR2d1; 60 } 61 62 m *= fractal->transformCommon.maxR2d1 / minR2; 63 if (fractal->foldColor.auxColorEnabledFalse) 64 { 65 aux.color += fractal->mandelbox.color.factorSp1; 66 } 67 } 68 else if (rr < fractal->transformCommon.maxR2d1) 69 { 70 m *= fractal->transformCommon.maxR2d1 / rr; 71 if (fractal->foldColor.auxColorEnabledFalse) 72 { 73 aux.color += fractal->mandelbox.color.factorSp2; 74 } 75 } 76 } 77 else if (rr < minR2) 78 { 79 m *= fractal->transformCommon.maxR2d1 / minR2; 80 if (fractal->foldColor.auxColorEnabledFalse) 81 { 82 aux.color += fractal->mandelbox.color.factorSp1; 83 } 84 } 85 else if (rr < fractal->transformCommon.maxR2d1) 86 { 87 m *= fractal->transformCommon.maxR2d1 / rr; 88 if (fractal->foldColor.auxColorEnabledFalse) 89 { 90 aux.color += fractal->mandelbox.color.factorSp2; 91 } 92 } 93 z -= fractal->transformCommon.offset000; 94 95 // scale 96 z *= m; 97 aux.DE = aux.DE * fabs(m) + 1.0; 98 } 99