# Change of base matrix between displaced and rotated coordinate systems

I have a function that solves a problem when a specific angle equals $$0$$. The same function can be used with non-zero angles if you compute the problem from other coordinate system.

The scheme of the problem is:

I need help to figure out the transformation matrix between these two coordinate system, both $$B_1 \to B_0$$ and $$B_0 \to B_1$$.

Thanks

$$B_1 \to B_0$$:
$$\begin{pmatrix}x\\\ y\\\ z\\\ 1\end{pmatrix}=\begin{pmatrix}1 & 0 & 0 & 0\\\ 0 & cos(ψ) & sin(ψ) & -h·tan(ψ)\\\ 0 & -sin(ψ) & cos(ψ) & 0\\\ 0 & 0 & 0 & 1\end{pmatrix}·\begin{pmatrix}x'\\\ y'\\\ z'\\\ 1\end{pmatrix}$$
$$B_0 \to B_1$$:
$$\begin{pmatrix}x'\\\ y'\\\ z'\\\ 1\end{pmatrix}=\begin{pmatrix}1 & 0 & 0 & 0\\\ 0 & cos(ψ) & -sin(ψ) & h·sin(ψ)\\\ 0 & sin(ψ) & cos(ψ) & h·sin^2(ψ)/cos(ψ)\\\ 0 & 0 & 0 & 1\end{pmatrix}·\begin{pmatrix}x\\\ y\\\ z\\\ 1\end{pmatrix}$$