If I have the following information about star A and Star B, how can I compute the distance between A and B?

  • Distance from Sol for Star A
  • Right Ascension/Declination of Star A
  • Parallax/Absolute Magnitude of Star A
  • Distance from Sol for Star B
  • Right Ascension/Declination of Star B
  • Parallax/Absolute Magnitude of Star B

I can use the parallax and absolute magnitude to compute distance from Sol, but I don't know how to get the distance between A and B.

Obviously there will be errors in the parallax, but I'm looking for a best effort means to calculate this.


I've implemented this in Java and made it available via this link:


I realize for actual science work most people wouldn't use Java, but this is for a project that is part of my Java portfolio.


3 Answers 3


If you know the right ascension and declension of the stars, then you know the angle between them (ie the A-Sun-B angle). Working this out is an exercise in spherical trigonometry. The cosine of angular separation of the stars $\cos(C)$ is given by $$\cos(C) = \sin(d_a)\sin(d_b) + \cos(d_a)\cos(d_b)\cos(r_a-r_b)$$

Where $d_i$ is the declension of the star $i$ and $r_i$ is the right ascension (in degrees or radians as necessary)

Then the distance between the stars is just an application of the cosine law. $$c^2=a^2+b^2 -2ab\cos(C).$$ In which $a$ and $b$ are the distances to each star and $c$ is distance between the stars.

  • 1
    $\begingroup$ Thank you. My trigonometry days are far behind me. $\endgroup$
    – Jason
    Mar 27, 2022 at 16:39

Alternative approach:

Right ascension + declination + distance are spherical coordinates. Apply a standard conversion from spherical to rectangular coordinates and the distance calculation becomes easy.

  • 2
    $\begingroup$ They're spherical coordinates, not polar. And there are a couple different conventions for specifying the angles that make up a spherical coordinates (not to mention that spherical coordinates tend to use a polar angle, whereas declination is measured from the reference plane)., so it probably would be best to include the actual calculations. $\endgroup$
    – notovny
    Mar 28, 2022 at 18:28
  • $\begingroup$ @notovny Yeah, I used the wrong word, but the idea is valid--the calculation is easy if you transform the coordinate system. $\endgroup$ Mar 29, 2022 at 2:33

The really, really easy way to find the distances between two stars with kown directions and distances from Earth is to use an application which calculates those distances.


What is the closest stellar neighbour to Sirius?

In my answer I say that my first impression is that Procyon would probably be the closest stellar neighbor to Sirius. Then I investigate a few stars, listing their differences in angles from the right ascension and the declination of Sirius, and also by how much their distances from Earth differ from that of Sirius.

And then I tried using an app which calculates the distance between two stars. And of all the star pairs I tried, Procyon was the closest to Sirius according to that online app.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .