I am currently reading a paper called Least-squares Meshes.
This paper kindly explains in detail the construction of a matrix to solve the problem.
Matrix Conf