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 * Gnarl deformation in 2D (from Mark Townsend), and Luca 2011
10 * @reference
11 * http://www.fractalforums.com/mandelbulb-3d/custom-formulas-and-transforms-release-t17106/
12
13 * This file has been autogenerated by tools/populateUiInformation.php
14 * from the file "fractal_transf_gnarl.cpp" in the folder formula/definition
15 * D O    N O T    E D I T    T H I S    F I L E !
16 */
17
18REAL4 TransfGnarlIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
19{
20	Q_UNUSED(aux);
21	REAL4 oldZ = z;
22	REAL4 tempZ = z;
23	REAL Scale = fractal->transformCommon.scale1;
24	REAL stepX = fractal->transformCommon.scale3D000.x; //-0.1;
25	REAL stepY = fractal->transformCommon.scale3D000.y;
26	REAL stepZ = fractal->transformCommon.scale3D000.z;
27	REAL Alpha = fractal->transformCommon.rotation.x; // 2.0f;
28	REAL Beta = fractal->transformCommon.rotation.y;	//-4.0;
29	REAL Gamma = fractal->transformCommon.rotation.z; //-0.1;
30
31	if (fractal->transformCommon.functionEnabledAx)
32	{
33		tempZ.x = z.x - stepX * native_sin(z.y + native_sin(Alpha * (z.y + native_sin(Beta * z.y))));
34		tempZ.y = z.y - stepY * native_sin(z.x + native_sin(Alpha * (z.x + native_sin(Beta * z.x))));
35		z = tempZ;
36	}
37
38	if (fractal->transformCommon.functionEnabledAxFalse)
39	{
40		REAL xx = z.x * z.x;
41		tempZ.x =
42			z.x
43			+ stepX
44					* (native_sin(Gamma * (z.y - xx) + native_sin(Alpha * (z.y + Beta * native_cos(z.y)))));
45		tempZ.y =
46			z.y
47			+ stepY * (native_sin(Gamma * (z.y + xx) - Alpha * native_sin(xx + Beta * native_cos(xx))));
48		z = tempZ;
49	}
50
51	if (fractal->transformCommon.functionEnabledAyFalse)
52	{
53		REAL xx = z.x * z.x;
54		REAL yy = z.y * z.y;
55		tempZ.y = xx
56							+ stepY
57									* (native_sin(yy * native_sqrt(fabs(z.y))
58																- Alpha * native_sin((yy + native_sin(Beta * yy)))));
59		tempZ.x = yy
60							- stepX
61									* (native_sin(
62										xx * native_sqrt(fabs(xx)) + native_sin(Alpha * (xx + native_sin(Beta * xx)))));
63		z = tempZ;
64	}
65
66	if (fractal->transformCommon.functionEnabledAzFalse)
67	{
68		tempZ.x = z.x - stepX * native_sin(z.z + native_sin(Alpha * (z.z + native_sin(Beta * z.z))));
69		tempZ.y = z.y - stepY * native_sin(z.x + native_sin(Alpha * (z.x + native_sin(Beta * z.x))));
70		tempZ.z =
71			(z.z - stepZ * native_sin(z.y + native_sin(Alpha * (z.y + native_sin(Beta * z.y))))) * Scale;
72		z = tempZ;
73	}
74	z.x *= Scale;
75	z.y *= Scale;
76
77	if (fractal->analyticDE.enabled)
78	{
79		if (!fractal->analyticDE.enabledFalse)
80			aux->DE = aux->DE * fabs(Scale) * fractal->analyticDE.scale1 + fractal->analyticDE.offset0;
81		else
82		{
83			REAL avgScale = length(z) / length(oldZ);
84			aux->DE = aux->DE * avgScale * fractal->analyticDE.scale1 + fractal->analyticDE.offset0;
85		}
86	}
87	return z;
88}