\section{Interpolation}\label{interpolation}\index{interpolation}

Interpolation functions, which calculate intermediate values, are used to make smooth parameter transitions between keyframes. There is no need for manual editing of every animation camera position and fractal parameters. 
frame. A limited number of keyframes is enough to define good looking animation.

\subsection{Interpolation types}\label{interpolation-types}

Parameters in Mandelbulber can be transitioned using several interpolation modes:

\begin{multicols}{3}
\begin{enumerate}
	
	\item None

	\item Linear

	\item Linear angle
	
	\item Akima	

	\item Akima angle
	
	\item Catmul-Rom

	\item Catmul-Rom angle
	
\end{enumerate}
\end{multicols}

The chart in figure \ref{interpolations} shows a comparison between different interpolation modes.

The choice of mode, greatly effects the animation.

\simpleImageWithCaptionFullWidth{img/manual/media/interpolations.png}
{Interpolation types}
{interpolations}

\subsubsection{Interpolation - None}\label{interpolation-none}\index{interpolation!none}

The parameter remains constant between keyframes. The parameter will change abrubtly at the any keyframe that has a change in value. This mode can be used with boolean values or with variables
which have to be kept at a constant value for a number of keyframes.

\simpleImageWithCaptionHalfWidth{img/manual/media/interpolation_none.png}
{Interpolation - None}
{interpolation_none}

\subsubsection{Interpolation - Linear}\label{interpolation-linear}\index{interpolation!linear}

The value of the parameter is interpolated using linear functions.

\[ y(x) = y_i + (x - x_i) \frac{y_{i+1} - y_i}{x_{i+1} - x_i}\] \[x_i  \leq x
\leq x_{i+1}\]

Changes of parameters are easy to predict. There are no overshoots. This
interpolation mode is good for fractal parameters and material properties. It is
generally not recommended to be used for camera or object movement paths, because of the abrubt changes of speed.

\simpleImageWithCaptionHalfWidth{img/manual/media/interpolation_linear.png}
{Interpolation - Linear}
{interpolation_linear}

\subsubsection{Interpolation - Linear angle}\label{interpolation-linear-angle}

This interpolation mode works like \emph{Linear}, but is prepared of angular
parameters. If value exceed 360 degrees, then will go back to zero.

\subsubsection{Interpolation - Akima}\label{interpolation-akima}\index{interpolation!Akima}

The Akima interpolation is a continuously differentiable sub-spline
interpolation. It is built from piecewise third order polynomials.

\[ y(x) = a_0 + a_1 (x - x_i) + a_2 (x - x_i)^2 + a_3 (x - x_i)^3\] \[x_i  \leq
x \leq x_{i+1}\]

This interpolation function produces smooth transitioning through the keyframes. It is very good for most animated parameters. It 
is used for camera and target animation and for many other parameters which
should be animated in a smooth way.

\simpleImageWithCaptionHalfWidth{img/manual/media/interpolation_akima.png}
{Interpolation - Akima}
{interpolation_akima}

\subsubsection{Interpolation - Akima angle}\label{interpolation-akima-angle}

This interpolation mode works like \emph{Akima}, but is written for angular
parameters. If a value exceeds 360 degrees, then it will reset back to zero.

\subsubsection{Interpolation - Catmul-Rom}\label{interpolation-catmul-rom}\index{interpolation!Catmul-Rom}

Catmull-Rom splines are cubic interpolating splines formulated such that the
tangent at each point $ y_i(x_i) $ is calculated using the previous and next
point on the spline.

\[ y(x) = 0.5 \begin{bmatrix} 1 & x-x_i & (x-x_i)^2 & (x-x_i)^3\end{bmatrix}
\begin{bmatrix} 0 & 2 & 0 & 0 \\ -1 & 0 & 1 & 0 \\ 2 & -5 & 4 & -1 \\ -1 & 3 &
-3 & 1 \\ \end{bmatrix} \begin{bmatrix} y_{i-1} \\ y_i \\ y_{i+1} \\ y_{i+2}
\end{bmatrix} \]

This interpolation gives very smooth results. Animated objects looks likethey are made
of springy materials. It can be used to animate fractal parameters and also the
camera path. This interpolation mode can produce oscillations, so it has to be used
carefully. Figure \ref{interpolation_catmulrom}, 
shows where interpolated values went below zero,  where all of the keyframe values were higher than zero. The ocsillation problem is commonly seen near the begining and end of an animation

\simpleImageWithCaptionHalfWidth{img/manual/media/interpolation_catmulrom.png}
{Interpolation - Catmul-Rom}
{interpolation_catmulrom}

\subsubsection{Interpolation - Catmul-Rom
	angle}\label{interpolation-catmul-rom-angle}

This interpolation mode works like \emph{Catmul-Rom}, but is prepared of angular
parameters. If value exceed 360 degrees, then will go back to zero.

\subsection{Catmul-Rom / Akima interpolation -
	Advices}\label{catmul-rom-akima-interpolation---advices}

\subsubsection{Collision}\label{collision}

Fast approaching the obstacle may cause inadvertent drag to the camera towards
the center of the object. It is recommended to maintain the principle that one
keyframe does not reduce the distance to the object more than five times.

\twoImagesWithTwoCaptionsFullWidth{img/manual/media/catmull-rom_collision.png}
{Catmul-Rom with collision}
{catmull-rom_collision}
{img/manual/media/catmull-rom_no_collision.png}
{Catmul-Rom without collision}
{catmull-rom_no_collision}

\subsubsection{Fly through the gap}\label{fly-through-the-gap}

It is recommended to place a keyframe at the point where the camera flies
through a hole / gap in the fractal.

\simpleImageWithCaptionSmallWidth{img/manual/media/catmull-rom_hole.png}
{Interpolation - Catmul-Rom path through a hole}
{catmull-rom_hole}

\subsubsection{Proper conduct cameras between
	objects}\label{proper-conduct-cameras-between-objects}

Figure \ref{catmull-rom_example} shows how keyframes should be located between objects to avoid collisions caused by interpolation functions.

\simpleImageWithCaptionSmallWidth{img/manual/media/catmull-rom_example.png}
{Interpolation - Catmul-Rom path evading different obstacles}
{catmull-rom_example}

\subsection{Changing interpolation types}\label{changing-interpolation-types}

To change the interpolation algorithm, right click on the parameter list and the
options appear. In this example the \emph{main\_DE\_factor} have been
changed from Akima to Linear. Interpolation type is color coded e.g. Linear
parameters are highlighted in grey.

\simpleImageWithCaptionFullWidth{img/manual/media/change_interpolation_type.png}
{Changing an interpolation type}
{change_interpolation_type}
