views:

764

answers:

3

I wonder if it is possible, as the Wiimote has 3 accelerometers, to convert the accelerometers readings to a 3D vector.

I know the trick to extract pitch/roll, but it only uses the X and Z accelerometers, and has the gimbal lock problem.

What I would like is a full 3D vector, that can be converted to a quaternion rotation representation.

+1  A: 

Thinking about it further, the accelerometers values are the components of the vector I was looking for... You only have to express the shortest arc between a reference vector and this vector as a quaternion.

For example, if accel is a (normalized) vector containing the accelerometer values:

reference = Vector3(0, 0, 1)
axis = crossp(accel, reference)
angle = acos(dotp(accel, reference))
q = Quaternion::from_xyzr(axis, angle)
rotation_matrix = q.matrix()

I chose {0, 0, 1} as the reference vector, because it is the values of the accelerometers at "rest position" (Wiimote on a table, pointing towards you).

This gives the same kind of movements the X/Z accelerometers pitch/roll conversion does, but without gimbal lock at vertical positions.

The only problem is you don't get information about rotations made on the earth gravity axis... I guess this is what the MotionPlus is made for.

Luper Rouch
A: 

Luper, i have tried your idea, using the acceleration values from the wiimote, but the vector is always pointing top-right.

i've noticed that the gforce vector seems better for some calculations, but i'm not sure yet on how to use it..

have you came up with any cool idea on using the wiimote orientations and other values for camera moving or even playing with objects in a 3d space?

thanks in advance,

Victor
'but the vector is always pointing top-right': what vector are you talking about ? Normally, you would rotate your vector (for example (0, 0, 1)) with 'rotation_matrix'
Luper Rouch
A: 

the vector that was always pointing to one direction (in this case top-right) was the accel vector. i haven't quite figured out the values from the accelerometer and what to do with them.

what i did was to use the gravity force vector on the above code and with that i could get the correct rotation for the camera to look around in my 3d scene.

i am trying to figure out now is how to make the camera look and walk on the direction it is looking..

would you know ?

Victor