Page 1 of 1

How to get a list of stars around some target?

Posted: 09.02.2013, 14:23
by captain_picard
Hi all,
I have the following question:
Is it possible to use Celestia and via a script or addon, to get a list of stars inside a radius of x lightyears around the currently selected object and highlight them, say with a colored reticule or something?

An example would be the following: Select a star, say Sirius, and then run the script in order to highlight all the stars in a 200ly radius. I understand that would mean a hell lot of stars (~200^3/3^3~10^5 in this case), but perhaps one could add further criteria like star type or brightness etc.

So, is this possible? BTW, I know that going to Navigation > Star Browser, I can do something similar, but it is not exactly what I want, ie to highlight them all at the same time. From a quick search that I did, I didn't find anything helpful.

An idea would be to do the selection and calculation a priori in some other program and then modify Celestia's star catalog to contain only these stars, but it would be nice to do it in real time.

Thanks for any pointers/help!

Cheers

Re: How to get a list of stars around some target?

Posted: 09.02.2013, 19:02
by jogad
Hi,

Have a look here
http://en.wikibooks.org/wiki/Celestia/C ... stia#stars

In the given example stars are selected by spectral type but you can choose the distance from a target or any creterion you want.

:mrgreen:

Re: How to get a list of stars around some target?

Posted: 09.02.2013, 19:10
by captain_picard
Awesome!!! It seems to be exactly what I am looking for!!! Many thanks dude :D

Cheers

Re: How to get a list of stars around some target?

Posted: 09.02.2013, 19:18
by Marco Klunder
Although already cross-posted by Jogad, here is an example code to mark stars from the actual selected star within a given distance of 100 LY
You can of course adjust the distance.

Code: Select all

obs = celestia:getobserver()
obs:setframe(celestia:newframe("universal"))
celestia:unmarkall()
celestia:setrenderflags{markers = true}

-- Set distance in Lightyears
distance = 100

i=0
number_of_stars = celestia:getstarcount()

actual_selection = celestia:getselection()
if actual_selection:type() == "star" then
   pos_actual_star = actual_selection:getposition()
   for star in celestia:stars() do
      distance_to = pos_actual_star:distanceto(star:getposition()) / 9460730472580.8
      if distance_to <= distance then
         label_string = string.format("%4.1f", distance_to)
         star:mark("gold" , "square", 4, 1, "" .. label_string, false)
      end
      i=i+1
      if math.fmod (i, 1000) == 0 then
         celestia:print("Starcount: " .. i .. " of total: " .. number_of_stars, 10, -1, -1, 2, 4)
         wait(0)
      end
   end
   celestia:print("Stars marked with distance to " .. actual_selection:name() .. " < " .. distance .. " LY.", 10.0, -1, -1, 2, 4)
   wait(10.0)
else
   celestia:print("Actual selection is NOT a star", 3.0, -1, -1, 2, 4)
   wait(3.0)
end


Marco

Re: How to get a list of stars around some target?

Posted: 09.02.2013, 19:34
by captain_picard
Many thanks dude, you rock!!!!

I will give it a try asap :)

Cheers

Re: How to get a list of stars around some target?

Posted: 09.02.2013, 22:41
by Marco Klunder
Small edits to the code in the above post.
Because the script was far, FAR, FAR to slow....

Marco

Re: How to get a list of stars around some target?

Posted: 10.02.2013, 10:32
by captain_picard
Thanks for the update on the script! I have just tried it and it works beautifully :)

Cheers