Given a line y = ax+b , I observe (with the graphing calculator) a rotation when the slope a is changed or when x is substituted for y and vice-versa.
But this does not allow me to produce any rotation I want.
Is there a formula that allows to produce any rotation desired, with any angle whatever?
To rotate about the origin, apply the rotation matrix $$ R(\theta) = \begin{pmatrix} \cos\theta & \sin\theta \\-\sin\theta &\cos\theta\end{pmatrix}$$ to the vector $\begin{pmatrix}x\\y\end{pmatrix}$. We get $$-x\sin\theta +y\cos\theta =a (x\cos\theta+y\sin\theta) + b.$$ Rearranging, this gives $$y(\cos\theta-a\sin\theta)=x(a\cos\theta+\sin\theta)+b,$$ or $$y = \frac{a \cos\theta+\sin\theta}{\cos\theta-a\sin\theta}x+\frac{b}{\cos\theta-a\sin\theta}.$$ Note that setting $\theta=0$ recovers the original equation.
The formula only works when $\cos\theta-a\sin\theta\neq 0$, but the case when this is equal to zero corresponds exactly to when the line is rotated to be vertical and hence cannot be put in the form $y=a'x+b'$.