given $n$ points of human hand throwing a ball find the direction of the throw.

64 Views Asked by At

I have the following problem

I was given an array of coordinates ($(x,y,z)$) of a human hand throwing a ball in a plane, (first point start of the ball throwing, until the last point which is the release of the ball).

I need find the direction of the throw (make an imitation of the throw in a computer program).

The solution I thought of is to calculate to $a$= and the $b$= and calculate $(b.x,b.y,b.z)-(a.x,a.y,a.z)$ but this method is not precise, hence the angle is not correct, I wonder if there is a more precious solution I could use, maybe use all array?

Any help will be appreciated, thanks.

1

There are 1 best solutions below

4
On BEST ANSWER

The direction of the throw will be tangent to the trajectory. You can calculate an approximation from the last two points in the array of coordinates. If your points are affected by errors, the first step is to find the plane of throwing. I would use a least square approach. Then in this plane, fit the last few points to a simple curve (say a parabola) and calculate the tangent numerically.

Let's suppose that the data given is in the format $(x_i,y_i,z_i)$ with $i=\overline{1,n}$. The equation of the best fit plane is $ax+by+cz+d=0$, with $a,b,c,d$ unknowns. You can also allow the following $a^2+b^2+c^2=1$, which are normalized coordinates. If you have three points, finding $a,b,c,d$ is easy. If all the points are in the plane, just take three non-collinear points and you have the answer. But how about if your data is affected by some random errors. Then what we want to minimize is the distance from the points to the plane. In fact, you want to minimize the sum of the square of the distances to the plane. For each point the distance is given by $$D_i=\frac{a x_i+by_i+cz_i+d}{\sqrt{a^2+b^2+c^2}}$$ The denominator is $1$ from our requirement about the $a,b,c$ values. Then you want to minimize $$\sum_{i=1}^nD_i^2=\sum_{i=1}^n(a x_i+by_i+cz_i+d)^2$$ Now take the derivatives with respect to $a,b,c,d$ and set them to zero: $$\frac{\partial}{\partial a}\sum_{i=1}^nD_i^2=\sum_{i=1}^n2x_i(a x_i+by_i+cz_i+d)=0$$ Repeating the same for $b,c,d$ you get a system of equations with coefficients containing terms like $\sum x_i^2$ or $\sum x_iy_i$. You just need to solve it.