equation in matrix form i have an equation 
$$\sum_{i=0}^m [w^{(i)}[(c-a^{(i)})-\frac{d^{(i)}(c-a^{(i)})\cdot d^{(i)}}{dis^2}]]=0$$
Where:
$a,b$ are two end points in a 3D Line. $d$ is a vector and vector $d=b-a$. the magnitude of the vector $|d|=dis$. I have many lines and therefore, i have many $a,b$ points. thats why above equation represent $a,d$ as $a^{(i)},d^{(i)}$ . However, this $dis$ is single scalar value and others have $3$ value components. this $\cdot$ is the dot product of the vector $c-a$ and vector $d$. $w^{(i)}$ is the weight (of a line).
As i said earlier, I have many points which represent different lines and thus i am using  $a^{(i)}$ and $d^{(i)}$ to represent a point on a line and direction vector of line. but I have a one point which is outside to the lines and represent as $c$. Assume $i$ is lasting from $0$ to $m$. If I say the coordinates of points $a^{(i)},b^{(i)}$ are as $(x_1,y_1,z_1)^{(i)},(x_2,y_2,z_2){(i)}$ respectively. and the coordinate of point $c$ as $(x_0,y_0,z_0)$. then
How do I convert this equation in to matrix form $[A][X] = [B]$. where $X$ represent the componenets of $c$ as this $(x_0,y_0,z_0)$ are unknown that i need to solve.
Please convert this equation to matrix form!
 A: What anon is suggesting is pictorially this:
$$
\sum_{i=1}^n w_i\left(\begin{bmatrix}
| \\
(c-a_i)\\
|
\end{bmatrix} - \begin{bmatrix}
| \\
\bar{d}_i\\
|
\end{bmatrix}\begin{bmatrix}
- &d_i^T&-
\end{bmatrix}
\begin{bmatrix}
| \\
(c-a_i)\\
|
\end{bmatrix}
\right)=0
$$
where $\bar{d}_i$ is the normalized $d_i$ (and dot product is commutative). Factoring out $c-a_i$ gives
$$
\sum_{i=1}^n w_i \underbrace{\left( I - \begin{bmatrix}
| \\
\bar{d}_i\\
|
\end{bmatrix}\begin{bmatrix}
- &d_i^T&-
\end{bmatrix}
\right)}_{P_i}\begin{bmatrix}
| \\
(c-a_i)\\
|
\end{bmatrix}=0
$$
You can take the $a_i$ terms to the other side. The remaining step is to find a way to include the sum into a matrix format:
$$
\underbrace{\begin{bmatrix}
w_1I &w_2I &\dots w_nI
\end{bmatrix}
\begin{bmatrix}
P_1\\P_2\\ \vdots \\P_n
\end{bmatrix}}_{A}\underbrace{\begin{bmatrix}|\\c\\|\end{bmatrix}}_{x} = 
\underbrace{\begin{bmatrix}
w_1I &w_2I &\dots w_nI
\end{bmatrix}
\begin{bmatrix}
P_1 & & \\ &P_2\\ &&\ddots \\&&&P_n
\end{bmatrix}
\begin{bmatrix}
a_1\\a_2\\ \vdots \\a_n
\end{bmatrix}}_{b}
$$
which is the $Ax=b$ form we wanted. Computationally, the form above is simply, ...ehm..., ridiculous. I just wanted to show you the general structure. 
A: Write $\hat{d}{}^i$ for $d^i/|d^i|$. Thus we can remove the factor of $dis^2$ from the original equation by replacing each $d^i$ with $\hat{d}{}^i$. Now let $\otimes$ denote the outer product. Furthermore note that the vector $\hat{d}{}^i(\hat{d}{}^i\cdot\vec{c})$ can actually be rewritten as the product $(\hat{d}{}^i\otimes\hat{d}{}^i)\vec{c}$, and similarly for the $a^i$s - I recommend checking this yourself  for good exercise. Now we can define the matrix $P=\sum_{i=0}^mw^i(I-\hat{d}{}^i\otimes\hat{d}{}^i)$ and the vector $\vec{\alpha}=\sum_{i=0}^m\vec{a}{}^i$. Let $I$ be the identity matrix. Then the original equation can be abridged to just $P(\vec{c}-\vec{\alpha})=\vec{0}$. You write $\vec{x}=\vec{c}$ and desire the equation $A\vec{x}=\vec{b}$. You should be able to see what you want to do from there.
