0

I'm getting 3D points from the Kinect via OpenNI. Let's say I have :

X = [93.7819,76.8463,208.386,322.069,437.946,669.999]
Y = [-260.147,-250.011,-230.717,-211.104,-195.538,-189.851]
Z = [958,942,950,945,940,955]

That's the points I was able to catch from my moving ball. Now I would like to be able to compute something like an interpolation or least square with those points to know the trajectory of the ball. I can then know where the ball is going and where it will hit the wall.

I'm not sure of which mathematical tool to use and how to translate it in C++. I've seen lots of resources for 2D interpolation (cubic,...) or least squares, but it seems that it's harder for 3D or I missed something maybe.

Best regards

EDIT : the question is marked as too broad by moderators, so I will reduce the scope with the responses I got : if I use 2D polynomial regression with the 3 plans separately (thx yephick), what can I use in C++ to implement it ?

Community
  • 1
  • 1
Kriegalex
  • 423
  • 6
  • 17
  • I found this [link](http://rosettacode.org/wiki/Polynomial_regression#C) which works with GNU Scientific Library. You can found GSL for VS2010 [here](http://wwwf.imperial.ac.uk/~shb104/c/files/other/UsingGSLwithVisualStudio.pdf) – Kriegalex Jul 06 '14 at 14:37

2 Answers2

2

For what you are interested in there's hardly any difference between 3D and 2D.

All you do is work with planes independently (XY plane, XZ plane, and YZ plane). This will reduce the complexity significantly and allow you to "draw" much simpler diagrams on a piece of paper when you work on this problem.

Once you figured the coordinates in each of the planes it is quite trivial to not only reconcile the coordinates into a 3D space but also provides an added benefit of error checking. For example an X coordinate found in XY plane should match (or be "close enough") to the same X coordinate found in XZ plane.

If the accuracy is not too critical you don't even need to go higher than the first power of polynomial approximation, using just a simple plain-old arithmetical average of the two consequential points.

YePhIcK
  • 5,816
  • 2
  • 27
  • 52
1

You can use spline interpolation to create a smooth trajectory.

If not in the "mood" to implement it yourself, a quick google search will give you open source libraries like SINTEF's SISL that have such functionallity.

Nikos Athanasiou
  • 29,616
  • 15
  • 87
  • 153