I want to get coordinate (x,y)
of a point B based on coordinate of point A and distance from the point A and an angle using Arcgis js API 4.x .
For example : i have point A in (a,b) the distance between A and B is 500m and the angle is 20°, how can i get (x,y) of B.
Advertisement
Answer
i fount the equation here, i implemented it and it works perfectly.
this is my simple :
JavaScript
x
15
15
1
const R = 6371e3; //rayon of the erth
2
let lat1 = 36.7538 * Math.PI / 180; // latitude in rad
3
let long1 = 3.0588 * Math.PI / 180; // longiture in rad
4
let d = 5000; //distance between the two points
5
let angle = (90-20)*Math.PI/180; // the angle between the 2 points in rad (20°)
6
const sigma = d / R;
7
const delLat = sigma * Math.cos(angle);
8
let lat2 = (lat1 + delLat) * 180 / Math.PI;//latitude of the destination point
9
const del = Math.log(Math.tan(lat2 / 2 + Math.PI / 4) / Math.tan(lat1 / 2 + Math.PI / 4));
10
// const q = Math.abs(del) > 10e-12 ? delLat / del : Math.cos(lat1);
11
const q = Math.cos(lat1)
12
13
const delLong = sigma * Math.sin(angle) / q;
14
let long2 = (long1 + delLong) * 180 / Math.PI; //longitude of the destination point
15