Wiimote orientation as a 3D vector

旧时模样 提交于 2019-12-07 21:04:34

问题


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:


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.



来源:https://stackoverflow.com/questions/1212242/wiimote-orientation-as-a-3d-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!