I first track the path of the ball in the image. The scatter points in the image are the x and y coordinates of the ball. I want to know the point where the ball hits the ground and the stick. In D1 the ball hits the ground and in D2 ball to stick In two cases, the ball changes direction and angle.
How can I find the point where the angle and direction change?
I wrote this code to find the angle between two points, but it does not give the correct output.
v1_theta = math.atan2(y1, x1)
v2_theta = math.atan2(y2, x2)
degree = (v2_theta - v1_theta) * (180.0 / math.pi)
x1, y1 - previous position of the ball
x2, y2 - current position of the ball
How can I find the point where the angle and direction change?
CodePudding user response:
The curve to the right of d1
suggests that you are modelling 2D motion with gravity. If we assume that all of the time intervals are the same, then it looks as if the ball hits the stick first, then the ground.
So we divide the trajectory into three parts: the path before the stick, the path between the stick and the ground, and the path after bouncing off the ground. If we disregard the transitions (i.e. the bounces), the only force is gravity. (It is worth checking for air resistance, but if there is any, it appears to be in the noise and negligible.)
Take the second derivative to measure gravity, then fit parabolae to those three paths. Solve for the intersections. (At each intersection you will have two velocities, so if you want to find the angle between them, you can use atan.)