# How to find the Azimuth Angle

Hello,
I am currently working on how to find the azimuth with only having information about two points on the globe. The information available due to previous code are longitude, latitude, altitude, and the distance in kilometers between the two points.

I have constructed equations and logical statements to help derive the angle, yet these are not working. Does anybody have an idea as to what is wrong with the code or if there is an easier way to go about solving this problem?

var geodesic = new Cesium.EllipsoidGeodesic(positions[0], positions[1]);
var Dist = (((geodesic.surfaceDistance.toFixed(2))/1000));
var lat1= positions[1].latitude;
var lat0= positions[0].latitude;
var lon1= positions[1].longitude;
var lon0= positions[0].longitude;
var yDist= Math.abs(lat1 - lat0)*(111.2);
var b = Math.acos(Math.cos(90- lat1)*Math.cos(90- lat0) + Math.sin(90-lat1)*Math.sin(90-lat1)*Math.cos(lon1- lon0));
var azi = Math.asin(Math.sin(90-lat1)*Math.sin(lon1-lon0)/Math.sin(b));

``````        if ((lat1 > lat0)&& (lon1 > lon0))
{
console.log(azi*100);
}
if ((lat1 < lat0)&& (lon1 < lon0))
{
console.log(180 - azi*100);
}

if ((lat1 < lat0)&& (lon1 > lon0))
{
console.log(180 - azi*100);
}

if ((lat1 > lat0)&& (lon1 < lon0))
{
console.log(azi*100 + 360);
}``````

Doesnâ€™t the EllipsoidGeodesic property startHeading give what you need?

And this site has lots of formulas: http://www.movable-type.co.uk/scripts/latlong.html

Regards, Willem

Yes, thank you I was not aware of that function. Now the problem is that I cannot manipulate the numbers outputted by startHeading. Any idea why that could be?

Thanks,

Andrew

The startHeading is probably read-only, it g****ets the heading at the initial point. EllipsoidGeodesic() defines a geodesic between the two points.
Not sure what you want to achieve, the coordinates of the end-point given the start-point, heading and distance?