gpt4 book ai didi

ios - 插值和预测 CLLocationManager

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:38 24 4
gpt4 key购买 nike

我需要获得至少 10 赫兹的更新用户位置,以便在驾驶时在 MapBox for iOS 中平滑地动画位置。由于 Core Location 每秒只提供一个点,我认为我需要做一些预测。

我试过了ikalman但是当每秒更新一次并以 10 赫兹查询时,它似乎没有任何区别。

请问我该如何解决?

最佳答案

您要寻找的是外推法,而不是内插法。

我真的非常惊讶互联网上关于外推的资源如此之少。如果您想了解更多,您应该阅读一些数值方法/数学书籍并自己实现算法。

也许简单的线性外推就足够了?

// You need two last points to extrapolate
-(double) getExtrapolatedValueAt:(double)x withPointA:(Point*)A andPointB(Point*)B
{
// X is time, Y is either longtitute or latitude.
return A.y + ( x - A.x ) / (B.x - A.x) * (B.y - A.y);
}
-(Point*) getExtrapolatedPointAtTime:(double)X fromLatitudeA:(Point*)latA andLatitudeB:(Point*)latB andLongtitudeA:(Point*)longA andLongtitudeB:(Coord*)longB
{
double extrapolatedLatitude = [self getExtraploatedValueAt:X withPointA:latA andPointB:latB];
double extrapolatedLongtitude = [self getExtrapolatedValueAt:X withPointA:longA andPointB:longB];
Coord* extrapolatedPoint = [Coord new];
extrapolatedPoint.longtitude = extrapolatedLongtitude;
extrapolatedPoint.latitude = extrapolatedLatitude;
return extrapolatedPoint;
}

不确定我的功能是否正确,但你可以在这里查看: http://en.wikipedia.org/wiki/Extrapolation

这真的很容易。

您应该实现线性外推法。如果您发现线性外推法不够用(例如对于曲线),您应该迭代并使用其他一些外推算法对其进行更改。

另一种方法是在动画中延迟 1 秒,并使用插值在两个已知点之间制作动画。我不知道这是否适合您的用例。

关于ios - 插值和预测 CLLocationManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28024109/

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