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 * max sin - cos
10
11 * This file has been autogenerated by tools/populateUiInformation.php
12 * from the file "fractal_transf_sin_and_cos_max.cpp" in the folder formula/definition
13 * D O    N O T    E D I T    T H I S    F I L E !
14 */
15
16REAL4 TransfSinAndCosMaxIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
17{
18	REAL4 oldZ = z;
19	REAL4 maxZ = z;
20	REAL4 sinZ = z;
21	REAL4 cosZ = z;
22	REAL4 sinCosZ = z;
23
24	if (fractal->transformCommon.functionEnabledAx)
25	{
26		sinZ.x = native_sin(oldZ.x * M_PI_2x_F / fractal->transformCommon.constantMultiplierA111.x)
27						 * fractal->transformCommon.scaleA1; // freq
28		cosZ.x = native_cos(oldZ.x * M_PI_2x_F / fractal->transformCommon.constantMultiplierB111.x)
29						 * fractal->transformCommon.scaleB1;
30		sinCosZ.x = sinZ.x * cosZ.x * fractal->transformCommon.scaleC1;
31		maxZ.x = max(max(sinZ.x, cosZ.x), sinCosZ.x);
32
33		if (fractal->transformCommon.functionEnabledFalse) maxZ.x /= (fabs(oldZ.x) + 1.0f);
34	}
35
36	if (fractal->transformCommon.functionEnabledAyFalse)
37	{
38		sinZ.y = native_sin(oldZ.y * M_PI_2x_F / fractal->transformCommon.constantMultiplierA111.y)
39						 * fractal->transformCommon.scaleA1; // freq
40		cosZ.y = native_cos(oldZ.y * M_PI_2x_F / fractal->transformCommon.constantMultiplierB111.y)
41						 * fractal->transformCommon.scaleB1;
42		sinCosZ.y = sinZ.y * cosZ.y * fractal->transformCommon.scaleC1;
43		maxZ.y = max(max(sinZ.y, cosZ.y), sinCosZ.y);
44
45		if (fractal->transformCommon.functionEnabledFalse) maxZ.y /= (fabs(oldZ.y) + 1.0f);
46	}
47
48	if (fractal->transformCommon.functionEnabledAzFalse)
49	{
50		sinZ.z = native_sin(oldZ.z * M_PI_2x_F / fractal->transformCommon.constantMultiplierA111.z)
51						 * fractal->transformCommon.scaleA1; // freq
52		cosZ.z = native_cos(oldZ.z * M_PI_2x_F / fractal->transformCommon.constantMultiplierB111.z)
53						 * fractal->transformCommon.scaleB1;
54		sinCosZ.z = sinZ.z * cosZ.z * fractal->transformCommon.scaleC1;
55		maxZ.z = max(max(sinZ.z, cosZ.z), sinCosZ.z);
56
57		if (fractal->transformCommon.functionEnabledFalse) maxZ.z /= (fabs(oldZ.z) + 1.0f);
58	}
59
60	// post scale
61	maxZ *= fractal->transformCommon.scale;
62	aux->DE *= fabs(fractal->transformCommon.scale);
63
64	if (fractal->transformCommon.functionEnabledMFalse)
65	{
66		switch (fractal->combo4.combo4)
67		{
68			case multi_combo4Cl_type1:
69			default: maxZ += oldZ; break;
70			case multi_combo4Cl_type2: maxZ *= oldZ; break;
71			case multi_combo4Cl_type3: maxZ += fabs(oldZ); break;
72			case multi_combo4Cl_type4: maxZ *= fabs(oldZ); break;
73		}
74	}
75
76	z = maxZ;
77
78	// analytic tweaks
79	if (fractal->analyticDE.enabledFalse) // temp
80	{
81		aux->DE = aux->DE * fractal->analyticDE.scale1 + fractal->analyticDE.offset1;
82	}
83	return z;
84}