The complete topography simulation algorithm was coded in C++. Most parts were implemented in a multi-dimensional way. Only a few functions were treated separately for the two- and three-dimensional cases, such as testing for ray-surface intersections, which requires bi- or trilinear interpolation in two and three dimensions, respectively. However, using the template mechanism of C++ [124], both cases are processed separately during compile time. In this way, heavy optimizations by the compiler, such as loop unrolling for iterations over the dimensions, are possible.