JavaScript/calculations.js
//Calculates angle between user's location and object's location
Calculates angle between user's location and object's location
Calculates angle between user ' s location and object ' s location
function calculateBearing(latB1, latB2, lonB1, lonB2) {
    let dLon = (lonB2 - lonB1);
    let y = Math.sin(toRadians(dLon))* Math.cos(toRadians(latB2));
    let x = Math.cos(toRadians(latB1))*Math.sin(toRadians(latB2)) - Math.sin(toRadians(latB1))*Math.cos(toRadians(latB2))*Math.cos(toRadians(dLon));
    let brng = toDegrees((Math.atan2(y, x)));
    return brng;
}
function calculateBearing ( latB1 , latB2 , lonB1 , lonB2 ) { let dLon = ( lonB2 - lonB1 ) ; let y = Math . sin ( toRadians ( dLon ) ) * Math . cos ( toRadians ( latB2 ) ) ; let x = Math . cos ( toRadians ( latB1 ) ) * Math . sin ( toRadians ( latB2 ) ) - Math . sin ( toRadians ( latB1 ) ) * Math . cos ( toRadians ( latB2 ) ) * Math . cos ( toRadians ( dLon ) ) ; let brng = toDegrees ( ( Math . atan2 ( y , x ) ) ) ; return brng ; }
Calculates angle between user's location and object's location
Calculates angle between user ' s location and object ' s location