# Compute Distance Between Stars

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.

Edit

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

https://gist.github.com/fergusonjason/fa4794dc0dc5d45f7a7ed12296577ed5

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.

• Related, if not a duplicate: astronomy.stackexchange.com/q/39595/31410 Mar 27, 2022 at 18:28
• I actually implemented a solution to this for an answer here: astronomy.stackexchange.com/a/48970/25729 Mar 30, 2022 at 2:28
• @GregMiller I've done so as well, however I'm not one of the cool Python kids. See my edit. Apr 23, 2022 at 13:35

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.

• Thank you. My trigonometry days are far behind me. 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.

• 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. Mar 28, 2022 at 18:28
• @notovny Yeah, I used the wrong word, but the idea is valid--the calculation is easy if you transform the coordinate system. 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.

See:

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.

https://www.wolframalpha.com/widgets/view.jsp?id=1ece06643e87f3c4d90813af5ee12223