Incorporating Constraints and Prior Knowledge into Factorization Algorithms - An Application to 3D Recovery