Wiimote orientation as a 3D vector

泪湿孤枕 提交于 2019-12-06 11:34:06

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.

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