code: def fitPlaneSVD(XYZ):
      
      [rows,cols] = XYZ.shape
      # Set up constraint equations of the form  AB = 0,
      # where B is a column vector of the plane coefficients
      # in the form b(1)*X + b(2)*Y +b(3)*Z + b(4) = 0.
      p = (np.ones((rows,1)))
      AB = np.hstack([XYZ,p])
      [u, d, v] = np.linalg.svd(AB,0)        
      # Solution is last column of v.
      B = np.array(v[3,:])
      coeff = -B[[0, 1, 3]]/B[2]
      return coeff
docs: Fit a plane to input point data using SVD