Ah, cool. I’m assuming you’re using dfhack to get that data?
Are you doing this for adventure mode or fortress mode? Or both?
So, from what I understand, what you want is the sun’s and moon’s position in the sky given a certain date and position? I think I remember an open source program that let you input latitude and longitude and date and showed you the sky for that position and time. I’ll see if I can find a link. Maybe you could use whatever method they are using, since from what I understand it’s basically what you want to do.
I found some stuff for getting the position of our sun given all the required parameters, but it doesn’t give enough data to get the rotation of the skybox, which I also need. Or at least, I don’t understand the math enough to infer it.
Moon phase would be automatic as long as the moon position is correct, or vise versa, I guess.
Also I don’t necessarily need it to be accurate to earth, since DF is not earth, so a lot of the calculations can be simplified.
Current best guess on how to do this would be to have the planet axis (around which the sun and moon move) rotate around a solar system axis, and correcting the day legth by adding or subtracting a day from the year, but something about it seems off.
Disclaimer: I’ve never played DF, so I don’t know anything about DF’s celestial mechanics. That said…
If you’re thinking of going that far, I’d place the planet at the centre of the system and have it rotate once per day. Keep in mind that 1 day will actually involve a rotation through 360 + 360/336 (361.0714(…)) degrees.
Have Sun on a circular path, and have it advance 360/336 (1.0714 and change) degrees per day. Have the sun’s path tilted by whatever the axial tilt of the DF planet is, so that you can have seasonal changes in day length.
Have the Moon on a separate circular path. The Moon’s synodic period is given as 25.85 days. In 25.85 days, the Sun will have moved 27.6964 (and a bit) degrees, meaning the Moon will have to cover 387.6964(…) degrees in 25.85 days. That’s 14.9979(…) degrees per day.
Make sure the path of the Sun and the path of the Moon are tilted relative to one another, otherwise there will be a solar eclipse every new moon.
Rounding errors may cause the dates of the new and full moon to drift over time, so you may want to quietly reset the positions on an annual basis.
If you’re going to go through the trouble of rotating the universe (so, the skybox?), then I wouldn’t bother rotating the planet. Just have the skybox rotate by 360 degrees per day, and the sun and moon rotate by 360 degrees + the numbers given above.
I didn’t mean rotating the planet itself, that’s impossible with my current setup, I just meant rotating the planet’s axis, around which everything else rotates, to simulate the sun angle changing as you go closer to the poles.
I got it working, more or less, but didn’t do the moon yet. It’s always full moon.
The moon seems to be following a path opposite from the sun (When the sun is south, the moon’s path is north, and vice versa); I assume this is correct?
Also, for now, I’ve decided to just assume that everywhere in the world is 45 degrees north, for the purposes of the sun, since DF has a more-or-less mideval europe theme. I might change that later, but for now I’m lazy.
If it’s always full moon, then yes, the moon will be high in the sky when the sun is low, and vice versa. Just keep in mind that once you start moving the moon, if it doesn’t follow at least a slightly different path from the sun, every new moon will also be a solar eclipse.