Created
January 14, 2024 16:00
-
-
Save mrsoftware/c46663e010a21def8f326eb391d5be7b to your computer and use it in GitHub Desktop.
Revisions
-
mrsoftware created this gist
Jan 14, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 }