簡體   English   中英

在旋轉矢量傳感器中使用標量分量?

[英]Use of Scalar component in Rotation-Vector-Sensor?

Android中“旋轉矢量傳感器”的標量組件的用途是什么?

文檔指出它是可選的,示例不使用它。 可選是否意味着並非所有支持傳感器的設備都支持它?

我習慣於四元數樣式的旋轉符號,其中前三個值定義矢量,而第四個值定義圍繞該矢量的旋轉。 但是android似乎使用了不同的方法。

正如文檔所說:

SensorEvent.values[0] Rotation vector component along the x axis (x * sin(θ/2)). Unitless 
SensorEvent.values[1] Rotation vector component along the y axis (y * sin(θ/2)). 
SensorEvent.values[2] Rotation vector component along the z axis (z * sin(θ/2)). 
SensorEvent.values[3] Scalar component of the rotation vector ((cos(θ/2)).1 

這是android使用的單位四元數(X,Y,Z,W)。 由於W = sqrt(X ^ 2 + Y ^ 2 + Z ^ 2),因此您可以使用值[0],值1 ,值[2]自己計算值[3]。 我的經驗是,大多數android設備都不輸出values [3]值。

可以將android(X,Y,Z,W)使用的四元數轉換為您正在使用的四元數(x,y,z,θ)

X=x * sin(θ/2)
Y=...
Z=...
W=cos(θ/2)

這樣就可以得到(x,y,z,θ):

x=X/sin(θ/2)
y=...
z=...
θ=arcsin(sqrt(X^2+Y^2+Z^2))*2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM