Polynomial Fit in Python with NumPy
In a previous project I visualized the trajectory of a ball that I threw vertically into the air with a real-time position, velocity and acceleration plot. Extending upon this project, I wanted to calculate and visualize a trajectory prediction based on a simple physics model. In this post, I will explain how I fit the model to the measured state of the ball and visualize the predicted trajectory.
Let’s start with the physics model for the ball. For simplicity, I am only considering the vertical movement of the ball, simplifying the problem to a one-dimensional one. Furthermore, I am only modelling the ball as soon as it leaves my hand and neglecting any air drag. This simply leaves us with a single constant force acting on the ball: gravity.
The force is calculated with the mass of the ball and the gravitational acceleration g, which is approximately 9.8m/s², depending on location and altitude. The…