Solution (source code)

= Solution

Write $\mathbf x=s\mathbf n+\mathbf v$, with $\mathbf v\cdot\mathbf n=0$. The <linear map> sends $s\mathbf n$ to $as\mathbf n$ and sends $\mathbf v$ to $a\mathbf v+b(\mathbf n\times\mathbf v)$. On the perpendicular <plane>, $\mathbf v$ and $\mathbf n\times\mathbf v$ are perpendicular vectors of equal length. Thus
$$
a\mathbf v+b(\mathbf n\times\mathbf v)
=\sqrt{a^2+b^2}\bigl(\cos\vartheta\,\mathbf v+\sin\vartheta\,\mathbf n\times\mathbf v\bigr),
\qquad\vartheta=\arctan(b/a).
$$
The expression in parentheses is a <rotation in three dimensions> by $\vartheta$ about the oriented $\mathbf n$ axis, with the positive direction fixed by the <cross product>. Therefore \b[the map scales the axial component by $a$, scales the perpendicular component by $\sqrt{a^2+b^2}$, and rotates the perpendicular <plane> by $\arctan(b/a)$]. Since $a,b>0$, the angle lies between zero and $\pi/2$. This is an <axis-angle decomposition>, with different axial and transverse scale factors.