Skip to content

Instantly share code, notes, and snippets.

@mrsoftware
Created January 14, 2024 16:00
Show Gist options
  • Select an option

  • Save mrsoftware/c46663e010a21def8f326eb391d5be7b to your computer and use it in GitHub Desktop.

Select an option

Save mrsoftware/c46663e010a21def8f326eb391d5be7b to your computer and use it in GitHub Desktop.

Revisions

  1. mrsoftware created this gist Jan 14, 2024.
    20 changes: 20 additions & 0 deletions yandexDirectionMapper.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    type Point struct {
    Lat float64
    Lng float64
    }

    func YandexDirectionMapper(old Point, new Point) (float64, float64) {
    length := math.Sqrt(math.Pow(new.Lng-old.Lng, 2) + math.Pow(new.Lat-old.Lat, 2))

    if length == 0 {
    return 0, 0
    }

    unitX := (new.Lng - old.Lng) / length
    unitX5 := float64(int64((unitX)*100000)) / 100000

    unitY := (new.Lat - old.Lat) / length
    unitY5 := float64(int64(unitY*100000)) / 100000

    return unitX5, unitY5
    }