V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
300
V2EX  ›  问与答

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

  •  
  •   300 · Aug 7, 2018 · 930 views
    This topic created in 2832 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   ·   2940 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 12:28 · PVG 20:28 · LAX 05:28 · JFK 08:28
    ♥ Do have faith in what you're doing.