Page 1 of 1

nearest objects function

Posted: 01.08.2004, 01:00
by Stormyman
Hi,

Would it be a big deal to create a function in the solar system browser that shows/selects the nearest objects to the current position ?
Similar to the star browser where on can make a list of the nearest stars.

It would be really cool if one could see a list of the nearest objects in general, indepedant from being a satellite, moon, asteroid,comet, planet or star.
Like if one is on the surface of earth something like 1. Earth 2. Hubble 3.ISS 4.Moon 5. Venus and so on :)

Re: nearest objects function

Posted: 01.08.2004, 21:42
by Harry
CELX is your friend here:
http://www.h-schmidt.net/celestia/show-nearest-objects_v1.0.celx

No nice UI, you still have to select manually, and it's not well tested (feel free to improve it).

Harald

Posted: 01.08.2004, 22:58
by symaski62
8)

:oops: 5 mal


moi travailler


MLY_PER_AU = 149597870.7 / KM_PER_MICROLY

object_list = {}
object_list.n = 0

function append(list, obj)
list.n = list.n + 1
list[list.n] = obj
end

function fill_object_list(node)
append(object_list, node)
for i,v in ipairs(node:getchildren()) do
fill_object_list(v)
end
end

fill_object_list(celestia:find("Sol"))
distance_map = {}

function cmp_lt(obj1, obj2)
return distance_map[obj1] < distance_map[obj2]
end

function human_readable_dist(dist)
if dist > 0.1 * MLY_PER_AU then
return string.format("%4f au", dist/MLY_PER_AU)
else
return string.format("%4.1f km", dist*KM_PER_MICROLY)
end
end
while true do
obs = celestia:getobserver()
pos = obs:getposition()
for i,v in ipairs(object_list) do
distance_map[v] = pos:vectorto(v:getposition()):length()
end
table.sort(object_list, cmp_lt)
txt = ""
for i = 1, 10 do
txt = txt .. string.format("%i. %s (%s)\n", i, object_list[i]:name(), human_readable_dist(distance_map[object_list[i]]))
end
celestia:print(txt, 5, -1, 1, 2, -6)
wait(0.1)
end



8) 10 ? plus bien