Wiimote方向作为3D矢量 [英] Wiimote orientation as a 3D vector

查看:115
本文介绍了Wiimote方向作为3D矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,由于Wiimote具有3个加速度计,是否有可能将加速度计的读数转换为3D向量.

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

我知道提取俯仰/侧倾的技巧,但是它仅使用X和Z加速度计,并且存在万向节锁定问题.

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

我想要的是一个完整的3D矢量,可以将其转换为四元数旋转表示.

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

推荐答案

进一步考虑,加速度计值我要寻找的向量的组成部分...您只需要表达参考向量和此向量(作为四元数)之间的最短弧线.

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.

例如,如果accel是包含加速度计值的(归一化)向量:

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()

我选择{0,0,1}作为参考向量,因为它是静止位置"(桌子上的Wiimote指向您)上的加速度计的值.

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).

这提供了与X/Z加速度计的俯仰/滚动转换相同的运动,但是在垂直位置没有万向节锁定.

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

唯一的问题是您没有获得有关在地球重力轴上旋转的信息...我想这就是MotionPlus的用途.

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.

这篇关于Wiimote方向作为3D矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆