V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
300
V2EX  ›  问与答

导航路线中如何吃掉已经走过的点

  •  
  •   300 · 2018 年 8 月 7 日 · 894 次点击
    这是一个创建于 2809 天前的主题,其中的信息可能已经有所发展或是发生改变。

    怎么才能将已经路过的点隐藏呢 ==

    img1

    因为存在路径重新规划的情况,所以不能留着尾巴(也没必要啊)

    现在的做法是数点算距离,判断离哪个点最近,但这样的话在掉头或者转弯的时候很容易出错(正好有一个点在旁边就当成 false 了)

    double lastPointDistance = 0;
    int increaseTimes = 0;
    int minValueIndex = 0;
    boolean canfindTheNearestPoint = false;
    for (int i = 0; i < routeArray.size(); i++) {
        if (distance(i) > lastPointDistance) {
            increaseTimes++;
        } else {
            increaseTimes = 0;
            minValueIndex = i;
        }
        if (increaseTimes >= 3) {
            canfindTheNearestPoint = true;
            break;
        }
        lastPointDistance = distance;
    }
    if (canfindTheNearestPoint == YES) {
        DrawlineFromIndex(minValueIndex + 1);
        TruncateCoordinatesArrayFromIndex(minValueIndex);
    }
    

    有什么建议吗(*  ̄︿ ̄)

    img2

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3062 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:47 · PVG 22:47 · LAX 07:47 · JFK 10:47
    ♥ Do have faith in what you're doing.