300
V2EX  ›  问与答

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

  •  
  •   300 · Aug 7, 2018 · 943 views
    This topic created in 2837 days ago, the information mentioned may be changed or developed.

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

    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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2729 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:55 · PVG 23:55 · LAX 08:55 · JFK 11:55
    ♥ Do have faith in what you're doing.