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.
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:
The Vega Neighborhood
- Red
- Fuschia
- Maroon
- Yellow
- Olive
- Green
- Lime
- Mint
- Teal
- Aqua
- Sky Blue
- Blue
- Purple
The Vega Neighborhood