...

Predicting a Ball Trajectory. Polynomial Fit in Python with NumPy | by Florian Trautweiler | Jan, 2025


Polynomial Fit in Python with NumPy

Ball Tracking and Trajectory Prediction

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.

Position, Velocity and Acceleration Plots with Prediction

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.

Gravitational Force acting on the Ball

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…

Source link

#Predicting #Ball #Trajectory #Polynomial #Fit #Python #NumPy #Florian #Trautweiler #Jan