gpt4 book ai didi

ios - iDevice 态度 : stabilising quaternion

转载 作者:行者123 更新时间:2023-11-28 21:52:54 27 4
gpt4 key购买 nike

我正在尝试使用 iDevice 的态度 self.motionManager.deviceMotion.attitude.quaternion设备放在 table 上,但值不一样。如何在不导致旋转不良的情况下稳定这些值?我正在使用设备姿态来旋转相机节点。

 (x = -0.0055437298906573507, y = -0.0078092851375721247, z = -0.041180405121897398, w = 0.999105828407855)
(x = -0.0061666945840810842, y = -0.0067849414785486747, z = -0.041464744435584115, w = 0.99909789881469635)
(x = -0.0057767614213563457, y = -0.0075097232630314727, z = -0.041803806548186787, w = 0.99908091506248087)
(x = -0.0054897030127900098, y = -0.0077124534854605253, z = -0.04219926058901851, w = 0.99906436410664467)
(x = -0.0052714642886002782, y = -0.0078368692177714049, z = -0.042675299607953819, w = 0.99904435034111316)
(x = -0.0050140321661910547, y = -0.0078121993123853265, z = -0.043041870709832147, w = 0.99903014288315972)
(x = -0.0050055928591862253, y = -0.0077335374133680208, z = -0.043505056503552082, w = 0.99901073392523531)
(x = -0.0049666831093899792, y = -0.007717140215596976, z = -0.043913562364765651, w = 0.99899318158145256)
(x = -0.0047768022686966614, y = -0.0078160798819143576, z = -0.044274861496884942, w = 0.99897739098280313)
(x = -0.0047310514463435671, y = -0.0078007790545880336, z = -0.044670164461142137, w = 0.9989601300379195)
(x = -0.004618244779613233, y = -0.0078641769042355775, z = -0.045003270721875412, w = 0.99894520978936451)
(x = -0.0049526705779270597, y = -0.0076127708990477733, z = -0.045411652395276572, w = 0.99892707371465494)
(x = -0.0053219441444451315, y = -0.0074858231291817018, z = -0.045723089011719641, w = 0.99891192729581401)
(x = -0.0056345717154138147, y = -0.0073613453524927486, z = -0.046005287981812061, w = 0.99889818083421522)
(x = -0.0056064974434034201, y = -0.0074105820596984404, z = -0.046130222648849362, w = 0.99889221291304886)
(x = -0.0053487406143112462, y = -0.0076910190187535112, z = -0.046331716108766401, w = 0.99888218088156866)


self.motionManager = [[CMMotionManager alloc] init];
self.motionManager.deviceMotionUpdateInterval = 1.0/20.0;
[self.motionManager startDeviceMotionUpdates];

最佳答案

您正在寻找的是 low pass filter — 一种将传感器输入中的高频信号(噪声、随机抖动)与低频信号(有意的用户 Action )分开的方法。

实时过滤器的典型公式如下:

newValue = (sampledValue * factor) + (lastValue * (1 - factor))

也就是说,您可以从 sampledValue(来自传感器的原始输入)和 < em>lastValue(newValue 在前一个时间步计算;确保在第一次计算时将其初始化为合理的值),factor 控制混合有多远。您可以调整因子 来控制通过滤波器的信号量。

您可以将此公式分别应用于每个 xyzw四元数的组成部分并得到一个模糊的结果。但是 a) 将相同的代码写四次并不是那么有趣,并且 b) 四元数有一些特殊的数学会导致这种方法随着时间的推移而崩溃。

相反,您可以将 CMQuaternion 变成 GLKQuaternion 并在一次调用 GLKQuaternionSlerp 中进行混合。 . (它会为你考虑特殊的数学。)

filteredAttitude = GLKQuaternionSlerp(lastAttitude, sampledAttitude, factor)

然后从您的 GLKQuaternion 创建一个 SCNQuaternion,您可以设置节点的方向。

关于ios - iDevice 态度 : stabilising quaternion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27660653/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com