Steve Hosgood wrote:

Erik:
The position of any astronomical object relative to a viewer standing on
the planet's surface is usually given as "altitude" and "azimuth" - with
the true horizon and true "North" used as the references. Normally, an
object is said to "set" when it crosses the visible horizon. Simple
rise/set programs assume that the visible horizon and true horizon are
the same.

Flightgear being one of them ...

It gets a bit more tricky in a flight sim because the visible horizon
will be significantly below the "true" mathematical one, and thus the
sun might well be visible even though it is below the true horizon. For
orbit simulators, it gets even more extreme.

Yes, I've wanted to fix that for some time, but never gotten to it.

Additional entertainment will be provided by the fact that and code for
FG needs to work with a WGS84 spheroid, meaning that the distance to the
earth's centre will vary with lat and long, but for *sun* rise and set,
that's probably not significant.

There's a great program called "ephem" which will yield all the routines
you could ever want, though the pointers to "sunriset.c" that someone
else posted here will likely do it too. Not sure of the licence for
'ephem' though.

Somewhere I've got source for my own home-written version of a sun
rise/set program that I wrote a very long time ago (1979 I believe).
I'll see if I can find what I did with it. It started life in Fortran,
but was converted to C ages ago, and will probably do the job just fine.
I'd be quite happy to GPL any such source if it isn't already.

I thought we could do it with the current code, but there is a chicken and egg problem; To change the time, it is first calculated and then set. The time setting code (or rather ephemeris update code) relies on the time setting code. I was hoping to get the data from the ephemeris code but it can get me the right data only after it has been set based on the same settings ...

Or in other words; we still do need some sort of offline code to calculate the sun_angle based on arbitrary time and position settings to update the lighting and planets and start positions.

Erik


_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to