Least squares curve fitting is widely used in various neighborhoods, such as industry, agriculture, and economy. The method of piecewise curve fitting is used to deal with some experimental studies with large amounts of data. It can not only be used for plane space points, but also for three-dimensional space points. Firstly, this article introduces the principles of curve fitting and least squares. Secondly, it clarifies the steps based on least square fitting and gives examples of improvements made based on the principle of least square fitting functions by some scientists. Finally, the piecewise curve fitting in the three-dimensional space is obtained using the least squares piecewise curve fitting. It lays a certain theoretical foundation for drawing the laws between data in three-dimensional space.