1/**
2 * Mandelbulber v2, a 3D fractal generator  _%}}i*<.        ____                _______
3 * Copyright (C) 2017 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 * rotation folding plane
10
11 * This file has been autogenerated by tools/populateUiInformation.php
12 * from the file "fractal_transf_rotation_folding_plane.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 TransfRotationFoldingPlaneIteration(
17	REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
18{
19	REAL4 zRot;
20	// cast vector to array pointer for address taking of components in opencl
21	REAL *zRotP = (REAL *)&zRot;
22	__constant REAL *colP = (__constant REAL *)&fractal->mandelbox.color.factor;
23	for (int dim = 0; dim < 3; dim++)
24	{
25		// handle each dimension x, y and z sequentially in pointer var dim
26		REAL *rotDim = (dim == 0) ? &zRotP[0] : ((dim == 1) ? &zRotP[1] : &zRotP[2]);
27		__constant REAL *colorFactor = (dim == 0) ? &colP[0] : ((dim == 1) ? &colP[1] : &colP[2]);
28
29		zRot = Matrix33MulFloat4(fractal->mandelbox.rot[0][dim], z);
30		if (*rotDim > fractal->mandelbox.foldingLimit)
31		{
32			*rotDim = fractal->mandelbox.foldingValue - *rotDim;
33			z = Matrix33MulFloat4(fractal->mandelbox.rotinv[0][dim], zRot);
34			aux->color += *colorFactor;
35		}
36		else
37		{
38			zRot = Matrix33MulFloat4(fractal->mandelbox.rot[1][dim], z);
39			if (*rotDim < -fractal->mandelbox.foldingLimit)
40			{
41				*rotDim = -fractal->mandelbox.foldingValue - *rotDim;
42				z = Matrix33MulFloat4(fractal->mandelbox.rotinv[1][dim], zRot);
43				aux->color += *colorFactor;
44			}
45		}
46	}
47	return z;
48}