Rubberbanding & Smoothing

Rubberbanding

  • ๊ทธ๋ฆฌ๋“œ ๊ธฐ๋ฐ˜์—์„œ ๋ถˆํ•„์š”ํ•œ ์ค‘๊ฐ„ ๋…ธ๋“œ๋ฅผ ์ง€์šฐ๋Š” ๊ณผ์ •
  • ์„ธ ๊ทธ๋ฆฌ๋“œ ๋˜๋Š” ์ง€์  ์‚ฌ์ด๊ฐ€ ํ†ต๊ณผ ๊ฐ€๋Šฅํ•œ ๊ณต๊ฐ„์ธ์ง€๋ฅผ ํ™•์ธ
    • ํ†ต๊ณผ ๊ฐ€๋Šฅํ•˜๋ฉด ์ค‘๊ฐ„ ์ ์€ ๋ฆฌ์ŠคํŠธ์—์„œ ์ œ๊ฑฐ
bool AStarPather::rubberbanding(
    const GridPos& first, 
    const GridPos& second,
    const GridPos& third)
{
    // ์„ธ ์ ์ด ์ด๋ฃจ๋Š” ์ „ ์˜์—ญ์„ ๋Œ€์ƒ
    int left = std::min(first.row, std::min(second.row, third.row)),
        right = std::max(first.row, std::max(second.row, third.row)),
        top = std::max(first.col, std::max(second.col, third.col)),
        bot = std::min(first.col, std::min(second.col, third.col));

    for (int i = left; i <= right; i++) {
        for (int j = bot; j <= top; j++) {

            // ํ•ด๋‹น ์˜์—ญ์ด ์ด๋™๊ฐ€๋Šฅํ•œ์ง€ ํ™•์ธ
            GridPos p{i, j};
            if (terrain->is_valid_grid_position(p)
                && terrain->is_wall(p))
                return false;
        }
    }

    // otherwise,
    return true;
}

Smoothing

  • Waypoint๋“ค์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์—์ด์ „ํŠธ๊ฐ€ ๊ฐ ์ง€์ ์„ ๊ฒฝ์œ ํ•˜๋ฉด์„œ ์ž์—ฐ์Šค๋Ÿฌ์šด ๊ณก์„ ์„ ๊ทธ๋ฆฌ๋ฉฐ ์ด๋™ํ•˜๋„๋ก ํ•˜๋Š” Post-processing

๊ณก์„ 

image
image

  • ๋‘ ์  A, B ์‚ฌ์ด์˜ ์  P๋ฅผ ์œ„์™€ ๊ฐ™์ด ํ‘œํ˜„
  • t์— ๋Œ€ํ•œ ๋ฐฉ์ •์‹
    • 1์ฐจ ๋ฒ ์ง€์— ๊ณก์„ 
    • ์  P์˜ ์ง‘ํ•ฉ, ์ฆ‰ A์™€ B๋ฅผ ์ž‡๋Š” ์„ ๋ถ„
  • ๊ฐ ์ ์„ ์ž‡๋Š” ์„ ๋ถ„ ๋˜๋Š” ๊ณก์„  ์œ„์˜ ์ ๋“ค์— ๋Œ€ํ•˜์—ฌ, ์ด๋“ค์„ ๋‹ค์‹œ ์„œ๋กœ ์ž‡๋Š”๋‹ค
  • n์ฐจ ๋ฒ ์ง€์— ๊ณก์„ ์€ n๊ฐœ์˜ ์ ๋“ค์— ๋Œ€ํ•ด ๋ฐ€๋„ t๋ฅผ ์กฐ์ ˆํ•ด๊ฐ€๋ฉฐ ๊ณก์„ ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค

์—ฐ์†์„ฑ

  • ์—ฌ๋Ÿฌ ๊ณก์„ ์„ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ž‡๋Š” ๋ฐฉ๋ฒ•
  • C0: ์ „์ฒด ๊ณก์„ ์ด ์—ฐ์†ํ•œ๋‹ค
  • C1: ๊ณก์„ ์ด ์—ฐ์†ํ•˜๊ณ , ๊ฐ ๊ณก์„ ์ด ๋งŒ๋‚˜๋Š” ๊ณณ์˜ ์ ‘์„  ๋ฒกํ„ฐ๊ฐ€ ๊ฐ™๋‹ค
    • 0์ฐจ, 1์ฐจ ๋„ํ•จ์ˆ˜๊ฐ€ ์—ฐ์†์ด๋‹ค
  • C2: ๊ณก์„ ์ด ์—ฐ์†ํ•˜๊ณ , ๊ฐ ๊ณก์„ ์ด ๋งŒ๋‚˜๋Š” ๊ณณ์˜ ์ ‘์„  ๋ฒกํ„ฐ๊ฐ€ ๊ฐ™๊ณ , ๊ณก๋ฅ ๋„ ๊ฐ™๋‹ค
    • 0์ฐจ, 1์ฐจ, 2์ฐจ ๋„ํ•จ์ˆ˜๊ฐ€ ์—ฐ์†์ด๋‹ค

Spline Points

image

  • ๋ณด๊ฐ„ ์Šคํ”Œ๋ผ์ธ์˜ ํ•œ ์ข…๋ฅ˜
  • 4๊ฒŒ ์ œ์–ด์ ์ด ์ฃผ์–ด์งˆ ๋•Œ ์ด๋“ค ๋ชจ๋‘๋ฅผ ๊ณก์„ ์„ ๊ทธ๋ฆฌ๋ฉฐ ํ†ต๊ณผํ•˜๋Š” ์„ ์„ ๊ทธ๋ฆฐ๋‹ค
    • ๋„ค ๊ฐœ ์ ์—์„œ ๊ณก์„ ์€ ์ค‘๊ฐ„ ์  2๊ฐœ ์‚ฌ์ด์— ์ •์˜๋œ๋‹ค

์บฃ๋ฉ€๋กฌ ์Šคํ”Œ๋ผ์ธ

image

  • s๋Š” ๋ฐ€๋„
  • 4๊ฐœ ์ ์„ ๋Œ€์ƒ์œผ๋กœ ๊ณก์„ ์„ ์ด๋ฃจ๋Š” ์ ๋“ค์„ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•

image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image

์˜ค๋ฅ˜

image

  • ๊ทธ๋ฆฌ๋“œ ๊ฐ„ World Distance๋ฅผ 1๋กœ ์žก์•˜์„ ๋•Œ, Rubberbanding ํ›„์˜ ๊ฐ ์  ์‚ฌ์ด์˜ ๊ฑฐ๋ฆฌ๊ฐ€ 1.5๋ฐฐ ์ด์ƒ์ด๋ฉด Smoothing ์‹œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค

image

  • ์ด ๊ฒฝ์šฐ back points๋ฅผ ์ƒˆ๋กœ ์‚ฝ์ž…ํ•ด์ค€๋‹ค
    • ๊ธฐ์กด์— ์žˆ๋˜ point ๋“ค์˜ ์ค‘๊ฐ„ ์ง€์ ์„ ๋ช‡ ๊ฐœ ๋” ๋ฐฐ์น˜ํ•œ๋‹ค
  • ๊ทธ ๋‹ค์Œ ์Šค๋ฌด์‹ฑ์„ ํ•ด์ค€๋‹ค

์ถœ์ฒ˜

Categories: ,

Updated: