Obtener dirección (brújula) con dos puntos de longitud / latitud

Estoy trabajando en una "brújula" para un dispositivo móvil. Tengo los siguientes puntos:

point 1 (current location): Latitude = 47.2246, Longitude = 8.8257
point 2 (target  location): Latitude = 50.9246, Longitude = 10.2257

También tengo la siguiente información (de mi teléfono Android):

The compass-direction in degree, wich bears to the north. 
For example, when I direct my phone to north, I get 0°

¿Cómo puedo crear una flecha de "brújula" que me muestre la dirección al punto?

¿Hay algún problema matemático para esto?

¡Gracias

EDIT: Ok, encontré una solución, se ve así:

/**
 * Params: lat1, long1 => Latitude and Longitude of current point
 *         lat2, long2 => Latitude and Longitude of target  point
 *         
 *         headX       => x-Value of built-in phone-compass
 * 
 * Returns the degree of a direction from current point to target point
 *
 */
function getDegrees(lat1, long1, lat2, long2, headX) {

    var dLat = toRad(lat2-lat1);
    var dLon = toRad(lon2-lon1);

    lat1 = toRad(lat1);
    lat2 = toRad(lat2);

    var y = Math.sin(dLon) * Math.cos(lat2);
    var x = Math.cos(lat1)*Math.sin(lat2) -
            Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
    var brng = toDeg(Math.atan2(y, x));

    // fix negative degrees
    if(brng<0) {
        brng=360-Math.abs(brng);
    }

    return brng - headX;
}

Esto funciona para mí genial!

Respuestas a la pregunta(8)

Su respuesta a la pregunta