How to find the Azimuth Angle

162 views
Skip to first unread message

Andrew Smith

unread,
Jul 9, 2015, 10:18:35 AM7/9/15
to cesiu...@googlegroups.com
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);
            }

Willem van der Gugten

unread,
Jul 9, 2015, 10:40:32 AM7/9/15
to cesiu...@googlegroups.com
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

Andrew Smith

unread,
Jul 9, 2015, 11:19:40 AM7/9/15
to cesiu...@googlegroups.com

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 

Willem van der Gugten

unread,
Jul 9, 2015, 2:13:29 PM7/9/15
to cesiu...@googlegroups.com
The startHeading is probably read-only, it gets 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?
Reply all
Reply to author
Forward
0 new messages