我試圖獲得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