I have a Straight Line of the form:
$\begin{pmatrix} P_{x'}\\ P_{y'}\\ P_{z'}\end{pmatrix} = \begin{pmatrix} A_{0}\\ B_{0}\\ 0 \end{pmatrix} + \begin{pmatrix} A_{1}\\ B_{1}\\ 1 \end{pmatrix} \cdot z'$
where those two vectors can be assigned the terms position and direction vectors.
I want to transform this line back into XYZ frame.
I know how the X'Y'Z' frame is related to the XYZ frame by the matrix M, were M=
$\begin{pmatrix} X'\cdot x & Y' \cdot x & Z'\cdot x\\ X' \cdot y & Y' \cdot y & Z' \cdot y\\ X' \cdot z & Y' \cdot z & Z' \cdot z\\ \end{pmatrix}$
Such that a position in X'Y'Z' is transformed to XYZ via:
$\vec{P}_{xyz} = \underline{\underline{M}} \cdot \vec{P}_{X'Y'Z'} $
I get how to do this for a position vector but how do I deal with the direction part?
Any help much appreciated.
There is a subtlety you are missing: $z^\prime$ is a parameter. The line is formed by varying $z^\prime$.
So, parameterize the line more generally as a vector-valued function of some parameter, $t \in \{-\infty,+\infty\}$. Then $\mathbf{P} \equiv \mathbf{P}(t)$ which can be represented in the primed basis as $\mathbf{P}(t) = x^\prime(t)\mathbf{x^\prime} + y^\prime(t)\mathbf{y^\prime} + z^\prime(t)\mathbf{y^\prime}$ . Let $z^\prime(t) = t$, so that $x^\prime(t) = A_0 + A_1t$, $y^\prime(t) = B_0 + B_1t$, and $z^\prime(t) = t$. Now, if you know the transformation $(x^\prime,y^\prime,z^\prime) \rightarrow (x,y,z)$, all you have to do is apply is to $(x^\prime(t),y^\prime(t),z^\prime(t))$ to obtain $(x(t),y(t),z(t))$, which will have a similar form ($x(t) = a_0 + a_1t$, $y(t) = b_0 + b_1t$, and $z(t) = c_0 + c_1t$), which you can write in a similar form as the equation you have above in the primed basis. $$\begin{pmatrix} P_{x}\\ P_{y}\\ P_{z}\end{pmatrix} = \begin{pmatrix} a_{0}\\ b_{0}\\ c_{0} \end{pmatrix} + \begin{pmatrix} a_{1}\\ b_{1}\\ c_{1} \end{pmatrix} t $$