From 9bc87247185c7b25f2c708eadf9eb9ad4568d33e Mon Sep 17 00:00:00 2001 From: zebastian Date: Mon, 24 Apr 2017 20:12:49 +0200 Subject: [PATCH] readded code lookup if lstlistings --- .../manual/chapters/iteration_loop.tex | 72 ++----------------- mandelbulber2/preamble.tex | 4 +- 2 files changed, 7 insertions(+), 69 deletions(-) diff --git a/mandelbulber2/manual/chapters/iteration_loop.tex b/mandelbulber2/manual/chapters/iteration_loop.tex index 7963b39..ac11473 100644 --- a/mandelbulber2/manual/chapters/iteration_loop.tex +++ b/mandelbulber2/manual/chapters/iteration_loop.tex @@ -5,7 +5,7 @@ \section{Iteration loop}\label{iteration-loop} This section explains the calculations within the iteration loop. -%A fractal formula is built from mathematical equations. These equations can be modifications of the Mandelbrot Set equation (e.g Mandelbulb), and also other mathematical equations. +A fractal formula is built from mathematical equations. These equations can be modifications of the Mandelbrot Set equation (e.g Mandelbulb), and also other mathematical equations. The equations are made from mathematical operators ($+, -, *, /$) and can include functions (e.g. $\sin, \cos, \tan, \exp, \log, sqrt, pow$) @@ -31,18 +31,7 @@ \subsubsection{Mandelbulb Power 2}\index{Mandelbulb} \nopagebreak \includegraphics[width=0.3\linewidth]{img/manual/media/formula_mandelbulb_power_2} & \begin{minipage}[b]{0.5\linewidth} - \begin{verbatim}[fontsize=\scriptsize] - double x2 = z.x * z.x; - double y2 = z.y * z.y; - double z2 = z.z * z.z; - double temp = 1.0 - z2 / (x2 + y2); - double newx = (x2 - y2) * temp; - double newy = 2.0 * z.x * z.y * temp; - double newz = -2.0 * z.z * sqrt(x2 + y2); - z.x = newx; - z.y = newy; - z.z = newz; - \end{verbatim} + \lstinputlisting[caption={Formula > Mandelbulb Power 2}]{code/formula_mandelbulb_power_2.cpp} \end{minipage} \end{tabular} @@ -55,75 +44,24 @@ \subsubsection{Menger Sponge}\index{Menger Sponge} \nopagebreak \includegraphics[width=0.3\linewidth]{img/manual/media/formula_menger_sponge.png} & \begin{minipage}[b]{0.5\linewidth} - \begin{verbatim}[fontsize=\scriptsize] - z.x = fabs(z.x); - z.y = fabs(z.y); - z.z = fabs(z.z); - - if (z.x - z.y < 0.0) swap(z.x, z.y); - if (z.x - z.z < 0.0) swap(z.x, z.z); - if (z.y - z.z < 0.0) swap(z.y, z.z); - - z *= 3.0; - - z.x -= 2.0; - z.y -= 2.0; - if (z.z > 1.0) z.z -= 2.0; - \end{verbatim} + \lstinputlisting[caption={Formula > Menger Sponge}]{code/formula_menger_sponge.cpp} \end{minipage} \end{tabular} \subsubsection{Box Fold Bulb Pow 2} -\nopagebreak This formula is made from a set of different transforms. It is a good example how a fractal formula can be more complicated than the \emph{Mandelbrot Set} formula. First part is a ``box fold''\index{transform!box fold} transform which conditionally maps the point in x,y,z directions. Second part is a ``spherical fold''\index{transform!spherical fold} which does conditional scaling in a radial direction. -The end of formula is the same as \emph{Mandelbulb Power 2}. \nopagebreak +The end of formula is the same as \emph{Mandelbulb Power 2}. \begin{tabular}{l l} \includegraphics[width=0.3\linewidth]{img/manual/media/formula_box_fold_pwr2.png} & \begin{minipage}[b]{0.5\linewidth} - \begin{verbatim}[fontsize=\scriptsize] - //box fold - if (fabs(z.x) > fractal->foldingIntPow.foldFactor) - z.x = sign(z.x) * fractal->foldingIntPow.foldFactor * 2.0 - z.x; - if (fabs(z.y) > fractal->foldingIntPow.foldFactor) - z.y = sign(z.y) * fractal->foldingIntPow.foldFactor * 2.0 - z.y; - if (fabs(z.z) > fractal->foldingIntPow.foldFactor) - z.z = sign(z.z) * fractal->foldingIntPow.foldFactor * 2.0 - z.z; - - //spherical fold - double fR2_2 = 1.0; - double mR2_2 = 0.25; - double r2_2 = z.Dot(z); - double tglad_factor1_2 = fR2_2 / mR2_2; - - if (r2_2 < mR2_2) - { - z = z * tglad_factor1_2; - } - else if (r2_2 < fR2_2) - { - double tglad_factor2_2 = fR2_2 / r2_2; - z = z * tglad_factor2_2; - } - - //Mandelbulb power 2 - z = z * 2.0; - double x2 = z.x * z.x; - double y2 = z.y * z.y; - double z2 = z.z * z.z; - double temp = 1.0 - z2 / (x2 + y2); - zTemp.x = (x2 - y2) * temp; - zTemp.y = 2.0 * z.x * z.y * temp; - zTemp.z = -2.0 * z.z * sqrt(x2 + y2); - z = zTemp; - z.z *= fractal->foldingIntPow.zFactor; - \end{verbatim} + \lstinputlisting[caption={Formula > Box fold Power 2}]{code/formula_box_fold_pwr2.cpp} \end{minipage} \end{tabular} diff --git a/mandelbulber2/preamble.tex b/mandelbulber2/preamble.tex index dea3707..b86b5ae 100644 --- a/mandelbulber2/preamble.tex +++ b/mandelbulber2/preamble.tex @@ -21,8 +21,8 @@ \usepackage[firstpage]{draftwatermark} \SetWatermarkLightness{0.9} -\SetWatermarkText{\tikz{\node[opacity=0.3]{ - \includegraphics[width=1.0\paperwidth, angle=-45]{img/mandelbulber_background.png}}}; +\SetWatermarkText{\tikz\node[opacity=0.3]{ + \includegraphics[width=1.0\paperwidth, angle=-45]{img/mandelbulber_background.png}}; } \usepackage[font={footnotesize,it}]{caption}