Sunday, April 26, 2020

Star Neighborhoods


I was talking to a friend about the distance of stars. He stated that he knew or could look up the distance from Earth to some star, but he had never seen published the distance from Starx to its neighboring stars. I said I have a list of stars in a MySQL table and I think one of them has the x, y, z coordinates.

Well, I was wrong, I do not have them recorded in the x, y, z coordinate system. But I do have Right Ascension, Declination and distance. The best table I have has 46,000 nearby stars and their RA, Dec and distance in Parsecs. Guess what, if One has RA, Dec. and distance, One can convert to the x, y and z coordinate system.

x = Sin(Dec) * Sin(RA) * Dist
y = Sin(Dec) * Cos(RA) * Dist
z = Cos(Dec) * Dist

With any two stars in an x, y, z coordinate, the distance between them can be calculated by:

Distance = ((x1-x2)2 + (y1-y2)2 + (z1-z2)2).5

The computer Language I like is Lazarus, which is an Object Pascal based “Rapid Application Development” or RAD System. It involves placing forms on the screen and then objects on those forms, One can then attach source code to each object. Lazarus itself and the Free Pascal it is based on generates relatively fast programs.

Lazarus can pull data out of MySQL tables using using ZeosDBO, all one has to do is put in the Database Name, your user and password and the table you want to access. So I wrote a little program to grab one star, like Vega, calculate it's x, y, z coordinates. select all the data out of the database table and load it into an array while calculating their x, y, z coordinates and distance from the primary star. Sort the output and display the nearest 50 or so stars.

This takes about 20 seconds to calculate, most of that is the sort. I used the ShellSort algorithm, I know the Quick Sort is the fastest, but with this amount of data the Shell Sort does as well, the Quick Sort algorithm doesn't start to out perform the Shell Sort until it reaches about 75,000 items to be sorted.

This all became a fun diversion during the Pandemic.

Here is an image of my program after calculating the star distances from Vega.  Well it turns out that one can have even more fun with this data.  It is possible to graph it.  Unfortunatly, I don't know how to graph it to a 3rd plane conventionally.  But it is possible to use color to represent distance on the x plane.  The following list maps color to distance with red being closest and purple being the furthest:

  1. Red
  2. Fuschia
  3. Maroon
  4. Yellow
  5. Olive
  6. Green
  7. Lime
  8. Mint
  9. Teal
  10. Aqua
  11. Sky Blue
  12. Blue
  13. Purple
The star catalog I am using only has 46,000 stars in it when we know there are over 1.0e+8 stars in our galaxy, so many stars aren't there.  The data I have is also less then perfect, so please be forgiving. The larger the dataset, the harder this will be to do. You may note that most stars name's begin with GL, well the Gliese names are the most populated of star names in my catalog.  The Poper and Bayer names are mostly blank. The distances very based on the neighborhood selected, I am seeing ranges on the low side of +/- 1LY and on the high side of +/-4LY. Here are a few of my graphs:

The Vega Neighborhood


The Sirius Neighborhood

Arcturus