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 * Transform Menger Fold
10 * Menger Sponge formula created by Knighty
11 * @reference
12 * http://www.fractalforums.com/ifs-iterated-function-systems/kaleidoscopic-(escape-time-ifs)/
13 * analytic aux.DE
14
15 * This file has been autogenerated by tools/populateUiInformation.php
16 * from the file "fractal_transf_menger_fold.cpp" in the folder formula/definition
17 * D O    N O T    E D I T    T H I S    F I L E !
18 */
19
20REAL4 TransfMengerFoldIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
21{
22	if (fractal->transformCommon.functionEnabledx)
23	{ // fabs() and menger fold
24		z = fabs(z + fractal->transformCommon.additionConstantA000);
25		if (z.x - z.y < 0.0f)
26		{
27			REAL temp = z.y;
28			z.y = z.x;
29			z.x = temp;
30		}
31		if (z.x - z.z < 0.0f)
32		{
33			REAL temp = z.z;
34			z.z = z.x;
35			z.x = temp;
36		}
37		if (z.y - z.z < 0.0f)
38		{
39			REAL temp = z.z;
40			z.z = z.y;
41			z.y = temp;
42		}
43	}
44	if (fractal->transformCommon.functionEnabledy)
45	{ // menger scales and offsets
46		z *= fractal->transformCommon.scale3;
47		z.x -= 2.0f * fractal->transformCommon.constantMultiplier111.x;
48		z.y -= 2.0f * fractal->transformCommon.constantMultiplier111.y;
49		if (fractal->transformCommon.functionEnabled)
50		{
51			if (z.z > 1.0f) z.z -= 2.0f * fractal->transformCommon.constantMultiplier111.z;
52		}
53		else
54		{
55			z.z -= 2.0f * fractal->transformCommon.constantMultiplier111.z;
56		}
57		if (fractal->analyticDE.enabled)
58		{
59			if (!fractal->analyticDE.enabledFalse)
60				aux->DE *= fractal->transformCommon.scale3;
61			else
62				aux->DE = aux->DE * fractal->transformCommon.scale3 * fractal->analyticDE.scale1
63									+ fractal->analyticDE.offset0;
64		}
65	}
66	return z;
67}