Now, the first thing I need for this I think is to determine the vectors from the observer to each star around the barycentre and then find the angle between them (like the phase angle calculation). The calculation should be fairly straightfoward, but I'm having trouble figuring out how to get the script to do this.
I think what I need is the getchildren command, but that seems to get EVERYTHING that is a 'child' of the barycentre, which would be stars, planets etc around the stars, and moons around the planets. How do I just get the stars out of this - and then 'isolate' them so that the script can get the vectors to each star from the observer?
I found this code on the CELX wiki that uses getchildren. I kinda get what it's doing - it's finding the 'children' of Saturn that have type "moon", but I don't understand syntax of the For statement (what's index? Why "index,body"? What's ipairs?. Harald's CelX page just shows the syntax, doesn't really explain what's going on there...
Code: Select all
-- tour the moons of Saturn
obs = celestia:getobserver()
planet = celestia:find("Saturn")
obs:goto(planet)
wait(5)
flash("Welcome to "..planet:name())
moons = planet:getchildren()
for index,body in ipairs(moons) do
if body:type() == "moon" then
obs:follow(body)
obs:goto(body)
wait(5)
flash("Welcome to "..body:name())
wait(1)
end
end