我试图获得Android设备的方向,我需要它在四元数结构(基本上是float[4]
)。如何从Android中的旋转矩阵中获得四元数?
我现在有是这样的:
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
last_acc = (float[])event.values.clone();
}
else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD){
last_mag = (float[])event.values.clone();
}
if (last_acc != null && last_mag != null){
SensorManager.getRotationMatrix(rotation, inclination, last_acc, last_mag);
SensorManager.getOrientation(rotation, orientation);
在“旋转”,我有4×4的旋转矩阵,并且在取向我有一个浮子[3]向量,其中我有方位角,俯仰和滚转。
我怎样才能得到四元数?
Thanx的答案。我认为这是我需要的。另外,解释它的谷歌视频非常清晰。 Thanx再次:) – Alex 2012-02-16 01:36:24
@亚历克斯很高兴听到它。祝你好运! – Ali 2012-02-16 08:33:06