Skip to content

Commit

Permalink
readded code lookup if lstlistings
Browse files Browse the repository at this point in the history
  • Loading branch information
zebastian committed Apr 24, 2017
1 parent 65264e1 commit 9bc8724
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 69 deletions.
72 changes: 5 additions & 67 deletions mandelbulber2/manual/chapters/iteration_loop.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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$)
Expand All @@ -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}

Expand All @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions mandelbulber2/preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 9bc8724

Please sign in to comment.