How can I calculate angles between objects at the sky?

1.1k Views Asked by At

There is a polar coordinate system which represents the sky from an observer.

The elevation angle is 0 to 90 degrees which corresponds to horizon to zenith.

The azimuth angle is 0 degrees (north) clockwise over east (90) till 360 degrees.

How can I calculate the angle between two objects at the sky? I have both angles in degrees for two objects as a starting point.

3

There are 3 best solutions below

0
On BEST ANSWER

Use the haversine formula. See the Wikipedia article for details

0
On

Did it in Python with:

import numpy as np

def haversine(azi1, alt1, azi2, alt2):
    """
    Calculate the great circle distance between two points 
    """
    # convert decimal degrees to radians 
    azi1, alt1, azi2, alt2 = map(np.deg2rad, [azi1, alt1, azi2, alt2])

    # haversine formula 
    dlon = azi2 - azi1 
    dlat = alt2 - alt1 
    a = np.sin(dlat/2)**2 + np.cos(alt1) * np.cos(alt2) * np.sin(dlon/2)**2
    c = 2 * np.arcsin(np.sqrt(a)) 

    return np.rad2deg(c)

Similar to https://stackoverflow.com/questions/4913349/haversine-formula-in-python-bearing-and-distance-between-two-gps-points.

0
On

Let the observer be $O$. First, project the two objects onto a unit sphere centred at $O$ (say to $A$ and $B$).

Second, drop a perpendicular line from each object to the horizontal plane (say the perpendicular feet are $A'$ and $B'$). Find the horizontal distances ($OA'$ and $OB'$) and vertical distances ($A'A$ and $B'B$) of the objects.

Third, notice $A'ABB'$ is a right-angled trapezium. The height of the trapezium, $A'B'$, can be found by considering $\triangle A'OB'$.

Lastly, with all these information, it is possible to find the slant height $AB$. Use $\triangle AOB$ to find $\angle AOB$.

Now, although this may not apply to your case, you may extend this reasoning for the case where one object is above horizon and the other is below horizon.