C
C
CheLord2020-11-11 15:00:57
satellite navigation
CheLord, 2020-11-11 15:00:57

How to return from atan2 angle back to coordinate?

With the help of atan2 and some trigonometric functions, I'm looking for the distance between two gps coordinates, but now the goal is to go back to the coordinates. Please help me find "x" and "y" which are in atan2.

final double RADIUS = 6372795;
    double a1 = 51.509069,a2 = 31.325302,b1 = 51.508628,b2 = 31.325986;
    double lat1,lat2,long1,long2;
    ////////////////////////////////////////////
    lat1 = a1*Math.PI/180;
    lat2 = b1*Math.PI/180;
    long1 = a2*Math.PI/180;
    long2 = b2*Math.PI/180;
    System.out.println ("x1-"+lat1+" y1-"+long1);
    System.out.println ("x2-"+lat2+" y2-"+long2);
    
    ///////////////////////////////////////////////
    System.out.println("косинусы и синусы широт и разницы долгот");
    
    double cl1 = Math.cos(lat1);
    double cl2 = Math.cos(lat2);
    double sl1 = Math.sin(lat1);
    double sl2 = Math.sin(lat2);
    
    System.out.println("косинусы "+ cl1+" "+cl2);
    System.out.println("синусы "+ sl1+" "+sl2);
    
    double delta = long2-long1;
    double cdelta = Math.cos(delta);
    double sdelta = Math.sin(delta);
    
    System.out.println("delta "+ delta+" "+cdelta +" "+sdelta);
    
    /////////////////////////////////////////////////////
    double y = Math.sqrt(Math.pow(cl2*sdelta, 2)+ Math.pow(cl1*sl2-sl1*cl2*cdelta, 2));
    double x = sl1*sl2+cl1*cl2*cdelta;
    
    double ad = Math.atan2(y, x);
    double dist = ad*RADIUS;
    System.out.println ("distanse - "+dist);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-11-11
@freeExec

googleпрямая геодезическая задача

T
Taus, 2020-11-11
@Taus

There are many such points on the sphere. For example, the set of points on the sphere equidistant from the chosen one on dist ( = ad*RADIUS)will be a circle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question