1/**
2 * Mandelbulber v2, a 3D fractal generator  _%}}i*<.        ____                _______
3 * Copyright (C) 2019 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 * 3D Version of the 2D Eye Fractal modified by mclarekin
10
11 * This file has been autogenerated by tools/populateUiInformation.php
12 * from the function "MandelbulbEyeTestIteration" in the file fractal_formulas.cpp
13 * D O    N O T    E D I T    T H I S    F I L E !
14 */
15
16REAL4 MandelbulbEyeTestIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
17{
18	// testing power2 thing, covert to non trig?
19	REAL4 c = aux->const_c;
20	aux->DE = aux->DE * 2.0f * aux->r;
21
22	if (fractal->buffalo.preabsx) z.x = fabs(z.x);
23	if (fractal->buffalo.preabsy) z.y = fabs(z.y);
24	if (fractal->buffalo.preabsz) z.z = fabs(z.z);
25
26	REAL4 zz = z * z;
27	REAL rr = zz.x + zz.y + zz.z;
28	REAL temp = native_sqrt(zz.x + zz.y);
29	REAL theta1 = atan2(temp, z.z) * fractal->transformCommon.scaleB1;
30	REAL theta2 = atan2(temp, -z.z) * fractal->transformCommon.scaleC1;
31
32	REAL phi1 = atan2(z.y, z.x) * fractal->transformCommon.scale1;
33	REAL phi2 = atan2(-z.y, z.x) * fractal->transformCommon.scaleA1;
34
35	z.x = rr * native_sin(theta1 + theta2) * native_cos(phi1 + phi2);
36	z.y = rr * native_sin(theta1 + theta2) * native_sin(phi1 + phi2);
37	z.z = rr * native_cos(theta1 + theta2);
38
39	/*REAL4 zzA = z * z;
40	REAL4 zzB = zzA; // * fractal->transformCommon.scaleD1;
41
42	REAL rrA = zzA.x + zzA.y + zzA.z;
43	REAL rrB = zzB.x + zzB.y + zzB.z;
44
45
46	REAL tempA = native_sqrt(zzA.x + zzA.y);
47	REAL tempB = native_sqrt(zzB.x + zzB.y);
48
49	REAL theta1 = atan2(tempA, zzA.z) * fractal->transformCommon.scaleB1;
50	REAL theta2 = atan2(tempB, -zzB.z) * fractal->transformCommon.scaleC1;
51
52	REAL phi1 = atan2(zzA.y, zzA.x) * fractal->transformCommon.scale1;
53	REAL phi2 = atan2(-zzB.y, zzB.x) * fractal->transformCommon.scaleA1;
54
55	REAL rrAB = rrA * rrB;
56
57	z.x = (rrAB) * native_sin(theta1 + theta2) * native_cos(phi1 + phi2);
58	z.y = (rrAB) * native_sin(theta1 + theta2) * native_sin(phi1 + phi2);
59	z.z = (rrAB) * native_cos(theta1 + theta2);*/
60
61	// addCpixel
62	if (fractal->transformCommon.addCpixelEnabledFalse
63			&& aux->i >= fractal->transformCommon.startIterationsE
64			&& aux->i < fractal->transformCommon.stopIterationsE)
65	{
66		REAL4 tempC = c;
67		if (fractal->transformCommon.alternateEnabledFalse) // alternate
68		{
69			tempC = aux->c;
70			switch (fractal->mandelbulbMulti.orderOfXYZ)
71			{
72				case multi_OrderOfXYZCl_xyz:
73				default: tempC = (REAL4){tempC.x, tempC.y, tempC.z, tempC.w}; break;
74				case multi_OrderOfXYZCl_xzy: tempC = (REAL4){tempC.x, tempC.z, tempC.y, tempC.w}; break;
75				case multi_OrderOfXYZCl_yxz: tempC = (REAL4){tempC.y, tempC.x, tempC.z, tempC.w}; break;
76				case multi_OrderOfXYZCl_yzx: tempC = (REAL4){tempC.y, tempC.z, tempC.x, tempC.w}; break;
77				case multi_OrderOfXYZCl_zxy: tempC = (REAL4){tempC.z, tempC.x, tempC.y, tempC.w}; break;
78				case multi_OrderOfXYZCl_zyx: tempC = (REAL4){tempC.z, tempC.y, tempC.x, tempC.w}; break;
79			}
80			aux->c = tempC;
81		}
82		else
83		{
84			switch (fractal->mandelbulbMulti.orderOfXYZ)
85			{
86				case multi_OrderOfXYZCl_xyz:
87				default: tempC = (REAL4){c.x, c.y, c.z, c.w}; break;
88				case multi_OrderOfXYZCl_xzy: tempC = (REAL4){c.x, c.z, c.y, c.w}; break;
89				case multi_OrderOfXYZCl_yxz: tempC = (REAL4){c.y, c.x, c.z, c.w}; break;
90				case multi_OrderOfXYZCl_yzx: tempC = (REAL4){c.y, c.z, c.x, c.w}; break;
91				case multi_OrderOfXYZCl_zxy: tempC = (REAL4){c.z, c.x, c.y, c.w}; break;
92				case multi_OrderOfXYZCl_zyx: tempC = (REAL4){c.z, c.y, c.x, c.w}; break;
93			}
94		}
95		z += tempC * fractal->transformCommon.constantMultiplier111;
96	}
97	z.x = fractal->buffalo.absx ? fabs(z.x) : z.x;
98	z.y = fractal->buffalo.absy ? fabs(z.y) : z.y;
99	z.z = fractal->buffalo.absz ? fabs(z.z) : z.z;
100	z += fractal->transformCommon.additionConstantA000;
101
102	/*REAL4 hypercomplex_pow_constant( REAL4 &vec1,  int n)
103	{
104		REAL r = native_sqrt(native_powr(vec1.x, 2) + native_powr(vec1.y, 2) + native_powr(vec1.z, 2));
105		REAL theta = atan2(native_sqrt(native_powr(vec1.x, 2) + native_powr(vec1.y, 2)), vec1.z);
106		REAL phi = atan2(vec1.y, vec1.x);
107
108		REAL new_x = native_powr(r, n) * native_sin(theta * n) * native_cos(phi * n);
109		REAL new_y = native_powr(r, n) * native_sin(theta * n) * native_sin(phi * n);
110		REAL new_z = native_powr(r, n) * native_cos(theta * n);
111
112		return (REAL4) {new_x, new_y, new_z, vec1.w};
113	}*/
114
115	if (fractal->analyticDE.enabledFalse)
116		aux->DE = mad(aux->DE, fractal->analyticDE.scale1, fractal->analyticDE.offset1);
117	return z;
118}