Wiimote Project

General Wiimote and Technology => Programmers Den => Topic started by: Dloop on March 22, 2010, 02:21:04 AM

Title: Help: Smoothing for 4 separate IR points
Post by: Dloop on March 22, 2010, 02:21:04 AM
Hi,

My first post here on the forums. Having a school project where we incorporate the Wiimote Whiteboard and been reading up on this site as it has a lot of useful information. But now I need some help and hoping some of you can be of service :)

I am using the library to send points to an interface for our game. The game is mostly a 2 player game but we added support for 4 points so one could incorporate teams of 2 instead in the future. So it is important for us to know the different points.

Now for the game to work well we need some kind of smoothing. This I am not sure how to make in a good way and need your help with. I think I need to be able to search the 2 or 4 last points to see which is closest to the new point to then make a smoothing calculation between the 2 and not between any of the other points.

How would you handle smoothing? And how would the algorithm for smoothing look?

Using C# as the game is made in XNA.

Thank you beforehand for any help with this.
Title: Re: Help: Smoothing for 4 separate IR points
Post by: boonjin on March 22, 2010, 06:52:26 AM
Hi,

You will just need to keep track on the position of the points and ensure that it is the same tracked point. This will not be difficult as the output for the tracked point should be close to previous states.

For the smoothing part, you can just take the average of past values. For a simple smoothing algorithm, you can take a look at the code I have written with Johnny Lee in Brian Peek's Coding4Fun, Wiimote Whiteboard chapter.

http://books.google.com/books?id=d1QC69atuocC&lpg=PA377&dq=wiimote%20whiteboard&pg=PA415#v=onepage

Hope this helps.

Regards,
Boon Jin
Title: Re: Help: Smoothing for 4 separate IR points
Post by: ujs on March 22, 2010, 11:33:48 AM
Hi,

How would you handle smoothing? And how would the algorithm for smoothing look?

smoothing isn't really rocket science:

Boon Jin is referring to http://en.wikipedia.org/wiki/Moving_average
If you want to get more fancy, e.g.: http://en.wikipedia.org/wiki/Exponential_smoothing

Btw, have you considered using the TUIO (http://www.tuio.org/) data from my app (link in my signature) as input to your game? This would save you the trouble of interacting with the Wiimote at all... just a suggestion.

Uwe