A
A
Alexey Gus2021-12-31 00:36:28
Geolocation
Alexey Gus, 2021-12-31 00:36:28

How to set points on the map at 90 degrees relative to another point?

In short, the point is, there are two points in the route. With their help, I get the azimuth, and I need to put two more points from the first point at 90 degrees to the left and right.
In some situations, everything works, but often it turns out wild ...

here is the code that I use, can anyone find a jamb?

// myAngele - азимут движения от точки с мигалкой до точки с машинкой
// 30 - расстояние от точки с мигалкой
          var p180= 180/pi;
          var dx =  p180 * ((cos(myAngele / 180 * pi) * 30) / 6378137) ;
          var dy =  p180 * ((sin(myAngele / 180 * pi) * 30) / 6378137) ;
          var dot_left_lan = dot_a.latitude + dy;
          var dot_left_lng = dot_a.longitude + dx / cos(dot_a.latitude);
          var dot_right_lan = dot_a.latitude - dy;
          var dot_right_lng = dot_a.longitude - dx / cos(dot_a.latitude);


61ce258d1e32d456951372.png

but sometimes it works fine xs because of what
61ce2658183db003340960.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-12-31
@Holyboom

And why doesn't anyone want to spend a couple of minutes searching for old questions on the #geolocation tag??
https://qna.habr.com/q/1052604
https://qna.habr.com/q/734847
https://qna.habr.com/q/649729 (see comments here
) there is a constant 6378137 in the code. Do you understand its meaning or was it just a copy-paste of a magic number?
Do you know that there are many different map projections ? And the formulas are very different for different projections. I strongly doubt that your maps are in the Mercator projection (somehow they don’t use it in navigators). Rather https://ru.wikipedia.org/wiki/Projection_Gauss_—_Kruger Therefore, read the answers on the links above (although the questions there were different, but the essence of the errors is the same).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question