Reposted with formatting (I am the anonymous poster also, hello world!):
First off a little explanation of my project. I've been writing a high
level WiimoteMote manager class in C# that talks to Brian's library
which provides the low level, basic data reported by the Wiiimote. My
manager facilitates the connection of multiple Wiimotes, and accessing
their data. It's also a static class that never needs to be
instantiated. It cleans up the mess of multiple Wiimote variable, and
the best part is that I no longer have to worry about the scope of my
Wiimotes, I have access to their data at all times, and there are no
globals.
Onto the math. Which always trips me up. My class is supposed to give
me higher level data, that has more practical usages. I have already
converted the Accelerometer data into degrees of 0-+/-180, which is
very handy when manipulating rotation matrices. But now I'm onto the IR
sensor which is probably the most important, and harder.
The Raw/Normalized data is almost useless when it come to IR. Once I
tilt the wiimote (which somrwhat happens naturally) the IR appear to
move in respect to the Wiimote. Once you hit a large angle, your
movements become completely misrepresented (actually they are being
represented x degrees off, where x=roll of wiimote). Open up Brian's
handy test app, rotate your wiimote 90 degrees and try to move those
dots, everything is 90 degrees off. In other word the Wiimote always
thinks its up-right, so when a dot "moves closer to the B button" it
thinks its going +y in wiimote spaces, but the user is moving it +\-x
in real world space.How do we counter act that mathematically,so that
no matter if my wiimote is rotated 0,45,90,180,76.92 degrees, moving my
arm up, equals moving the cross hair up.
I found this algorithm on
WiiBrew.org, in case it helps: Once we know the two dots of the sensor
bar, we rotate the sensor field to make the two dots appear on a
horizontal line (using the accelerometer values to make sure we're in
the right quadrant if the wiimote is upside down). The angle of
rotation corresponds to the angle of the wiimote as reported to the
software.
Thanks,
~Quinn