I have an issue with following problem:
A line needs to be intersected with a cosinus function.
My line would be
$\displaystyle l_1 = \binom{x_1}{y_1} + s\binom{u_1}{v_1}$
My function for a curved line in 2D is
$\displaystyle g: y_2 = d + a + a * (-cos(f * x_2))$
I need the first intersection (the smallest s > 0). How do I do that? I stand at
$s * v_1 + a * cos(f * (x_1 + s * u_1)) = y_1 - a - d$
and have no idea how to solve for s from here.
Your expression is of the form $s+A\cos(b+c\ s) = d$. Generally, you can't give an expression for the solution - it can only be done numerically.
By a linear transformation, this can be written as $p x+q\cos(x) = r$. When mathematicians noticed that they often needed to solve $x e^x = y$ for $x$, they invented a function (the Lambert W function) that solved it. Similarly, you could create a function (the Roth C function) that solves $\cos(x)/x = y$ for $x$ and give the solution to your equation in terms of $C$.
Until such a function exists, you will have to be content with solving the equation numerically.