I tried to mark all Trojan asteroids, using a couple of criteria which didn't work. Not finding anything appropriate at Harald's documentation, I tried some guesses, so I am not surprised they didn't work. I'm sure somebody here would know the right method. I tried object:getinfo().orbitSemiMajorAxis (to decide according to orbit). I also tried object:getinfo().orbitPeriod (to decide according to the period of Jupiter), which IS documented by Harald, but it also didn't work. I would favor a filter according to orbit, which could easily be extended to paint families of asteroids with different colors.
Using only the Trojans as asteroids in Celestia (Selden's 4 ssc files, from Motherlode) works nice, of course, and gives a beautiful rendition of the swarms that accompany Jupiter. This is the code (it marks all the asteroids; my unsuccessfull attempts to filter by orbit or period are there, commented out).
Code: Select all
-- Mark all Jupiter Trojan asteroids
-- Initializations
celestia:unmarkall()
trojans = {}
trojans.len = 0
t=1
-- Fill trojans with solar system objects
function filltable(obj)
local i, v
local children = obj:getchildren()
for i, v in children do
-- This does not work:
-- r = v:getinfo().orbitSemiMajorAxis
-- if v:type() == "asteroid" and r => 5.05 and r <= 5.40 then
-- This also does not work:
-- p = v:getinfo().orbitPeriod
-- if v:type() == "asteroid" and p >= 11 and p<=12 then
-- This works, but watch out, it will mark ALL asteroids:
if v:type() == "asteroid" then
trojans[trojans.len] = v
trojans.len = trojans.len + 1
end
end
end
-- Mark Trojans
function mark_trojans(trojans)
while t < trojans.len do
trojans[t]:mark( "red", "disk", 1, 0.5 )
t = t+1
end
end
-- Main
--
sol = celestia:find("Sol")
filltable(sol)
mark_trojans(trojans)
-- Go to some nice viewpoint to see the swarms
celestia:select(sol)
observer = celestia:getobserver()
observer:gotolonglat(sol,0,0.5,5e9,10)
observer:follow(sol)
celestia:settimescale(5e6)
celestia:show("markers")
celestia:show("orbits")
Cheers,
Guillermo