A TADS3/adv3 module for computing the constellations visible in the night sky

There are quite a few eager TADS helpers on here!

4 Likes

Okay, why not. The module has been updated to include the planets.

There’s now a DynamicEphem class for everything with varying (for our purposes) RA and DEC, and a Planet subclass of it that has logic for computing the RA and DEC from the object’s Keplerian elements.

Internally the module uses the Earth-Moon barycenter to compute the RA/DEC, so there will be slight parallax versus a specific viewing position on the surface of the earth. But that’s way, way below the rounding error of reporting integer angles, which the module already does.

It also computes the planets’ RA/DEC only once per Julian day.

The underlying logic is split up into separate methods to compute the orbital elements at a specific Julian date, compute the argument of perihelion and mean anomaly for the given time, computing the eccentric anomaly by iteratively solving Kepler’s equation until the delta falls below a given threshold, computes the heliocentric coords in the orbital plane, converts those coordinates into heliocentric equitorial coordinates, and coverts those coordinates into geocentric (or rather Earth-Moon-barycentric) coordinates, and then converts that into apparent celestial RA/DEC (from the E-M barycenter).

The point being that in principle this means that you should be able to use the same logic to compute the apparent position of arbitrary other objects (assuming you know the orbital elements for them).

Anyway, the new catalog is planets, catalog ID “planets”, and each Ephemeris instance is accessible as an object whose name is the planet’s common name in lower case (mercury, venus, and so on). Earth is emBarycenter, and is not part of the catalog (because it’s not an object in the sky). The Moon and Sun aren’t included in the planetary catalog (because they’re already handled by simpler methods as one-offs elsewhere in the module).

None of the visible planets are above the horizon in the example we’ve been using, but if we skip ahead a few hours:

>set date 1979 6 22 7
It is now 7:00 June 22, 1979.

Season: summer
Phase of Moon: new

>set catalog planets
Catalog set.

>map sky
Time: Fri Jun 22 07:00:00 1979
............*************............ ():  Sun
........*****...........*****........ *:   Polaris
......**.....................**...... @:   Moon
....**.........................**.... Jup: Jupiter
...*..............*..............*... Mar: Mars
..*...............................*.. Ven: Venus
.*.................................*.
**.................................**
*...Jup.............................*
*...................................*
*...........()......................*
**............VenMar...............**
.*.................................*.
..*...............@...............*..
...*.............................*...
....**.........................**....
......**.....................**......
........*****...........*****........
............*************............

>
5 Likes

Max - go for it!

I’ve been “learning” TADS for a few months now.
It has not been easy, but in the last few weeks, everything is beginning to make sense.

The answers truly are in the documentation, it’s just difficult because sometimes, you do not know what you’re actually looking for. That’s where forum members here really help out. Don’t hesitate to ask!

Good Luck!
Deborah

4 Likes

Another minor feature update: compile-time caching of dynamic objects.

To enable caching, just add the number of days (including the start date) you want to cache:

modify gameEnvironment
        cacheDays = 10
;

…to cache the first ten days, starting with the start date.

The default value is 0, which means nothing will be cached (independent of the options discussed below).

You can specify the catalogs to cache via gameEnvironment.cacheCatalogs, which is a List of catalog IDs. By default the “planets” catalog is cached.

In addition, the position of the Sun and Moon are cached as well.

Caching affects save file size, but it’s pretty minor. Caching a full year yields a savefile that’s about half a meg.

1 Like

Another update, although not to the module itself. There’s now a separate nightSkyView module to handle in-game viewable constellations, stars, and so on.

First an example. First, we’re revisiting the skies over Cambridge, Mass. on June 22, 1979. To refresh everyone’s memory, that looks like:

Time: Fri Jun 22 21:00:00 1979
............*************............ *:   Polaris
........*****...........*****........ Aql: Aquila
......**.....................**...... Aqr: Aquarius
....**.........................**.... Boo: Bootes
...*.......Cas....*.......UMa....*... Cas: Cassiopeia
..*...............................*.. Cyg: Cygnus
.*.................................*. Lib: Libra
**.................................** Lyr: Lyra
*...Peg....Cyg......................* Peg: Pegasus
*..............Lyr......Boo.........* Sco: Scorpius
*...................................* Ser: Serpens (Cauda)
**...............................Vir* Ser: Serpens (Caput)
.*.........Aql.........Ser.........*. Sgr: Sagittarius
..*.Aqr..........Ser..............*.. UMa: Ursa Major
...*.......................Lib...*... Vir: Virgo
....**.........................**....
......**......Sgr...Sco......**......
........*****...........*****........
............*************............

The demo has two rooms, one indoors and one outdoors. The player starts indoors. There’s a check that throws a generic failure message whenever the player attempts to examine any sky objects while indoors (windows and so on have to implement their own bespoke checks):

Room Indoors
This is a room indoors.

>x lyra
You can't see the sky from here.

Once outdoors, the module will attempt to describe the position of any visible object, or report that the object isn’t visible:

>x lyra
Lyra is near zenith in the east.

>x pegasus, aquarius, virgo
Pegasus is in the east.  Aquarius is in the southeast.  Virgo is low in the
west.

>x orion, gemini
You can't see Orion and Gemini.

>

In addition, sky objects will not be visible during the day:

>set date 1979 6 22 10
It is now 10:00 June 22, 1979.

Season: summer
Phase of Moon: new

>x orion
You can't see celestial objects during the day.

>

There are a few corner cases still on the todo list: the moon (and sun!) should be visible during the day, and I plan on adding the ability to attach descriptions to catalog objects (instead of just describing their position). But again I’m not sure how much of this is going to end up module code as opposed to game-specific code.

3 Likes