Vector Projection with respect to another vector I have learnt about orthogonal projections, but now there is a new problem regarding non orthogonal projections. As seen in the image, given vector d, i would like to project vector v to the line with a normal (n), with respect to d. How do I find the transformation matrix to do this? only d and n is given. 
 A: I think what you're trying to do is this: 
Given vectors $v$, $n$, and $d$, you want a vector $v'$ such that $v'\perp n$ and $v-v'$ is parallel to $d$. So write $v-v'=kd$ for some unknown scalar $k$, and take the dot product with $n$; you get $$k(n\cdot d)=n\cdot(v-v')=n\cdot v-n\cdot v'=n\cdot v$$ so $$k={n\cdot v\over n\cdot d}$$ and then $$v'=v-kd=v-{n\cdot v\over n\cdot d}\,d$$
A: Isn't he asking for the transformation matrix?
Working further from @Gerry's answer (and thanks the beloved Dirac's notation):
$$
\begin{align}
v' & =v-{n\cdot v\over n\cdot d}\,d \\
   & =\lvert v\rangle\,-\,\lvert d\rangle \,{\langle n,v\rangle \over \langle n,d\rangle} \\
   & =\lvert v\rangle-{\lvert d\rangle \langle n,v\rangle \over \langle n,d\rangle} \\
   & = \lvert v\rangle-{\lvert d\rangle \langle n\rvert  \over \langle n,d\rangle} \lvert v\rangle \\
  & = \left(1-{\lvert d\rangle \langle n\rvert  \over \langle n,d\rangle}\right)\,\lvert v\rangle \\
  & = \left(1-{ {\, d \, n^T} \over (n,d)}\right) v
\end{align}
$$
The expression in paretheses is the transformation matrix that you wanted. 
For the impatient, a mini crash course on Dirac's notation:


*

*every ket $\lvert a\rangle$ works as a column vector

*every bra $\langle b\rvert$ works as the corresponding row vector, i.e. as $b^T$ (where transposion implies conjugation if vectors are in $\mathbb{C}^D$)

*$\langle b\rvert \, \lvert a\rangle$ or simply $\langle b,a\rangle$ is a number. It is the scalar product $(b,a)$ here above written $ \, b \cdot a\,$ (in matrix notation, $\,b^T a \,$, which is not commutative, but pseudo-commutative as it turns into its conjugate when exchanging factors. This is to make $\langle a,a\rangle$ the square norm of a, which must always be real). Note that, being a number, it can be multiplied with vectors of both kinds on the right and on the left interchangeably (i.e. commutatively)

*$\lvert a\rangle \, \langle b\rvert $ is the matrix $\,a \, b^T \, $
