$ show da-luce/astroterm
Astroterm is a terminal-based star map application written in C. It renders the real-time positions of stars, planets, the Moon, and constellation figures using ASCII or Unicode characters. The system computes celestial positions from the Yale Bright Star Catalog, Keplerian orbital elements, and user-specified date/time and location (latitude/longitude or city name). It projects the visible sky onto the terminal via a stereographic projection and uses ncurses for display and input. The build system is Meson with Ninja, supporting Linux, macOS, and Windows. The codebase is well-structured into separate modules for astronomy calculations (astro.c), coordinate transforms (coord.c), terminal rendering (drawing.c, term.c), and data parsing (parse_BSC5.c, city.c). It includes comprehensive unit tests using Unity and CI via GitHub Actions. The application is highly configurable through command-line arguments and demonstrates strong craftsmanship in astronomical computations and terminal graphics.
The LLM identified 4 files worth highlighting for reuse:
Implements core astronomical calculations: Kepler equation solver, planetary helio/geocentric ICRF positions (using JPL elements), lunar position (Schlyter algorithm), sidereal time, Julian date conversions, moon phase, and zodiac signs. This module is self-contained with only standard math and local header dependencies, making it reusable as a standalone astronomy library.
Provides coordinate conversions (equatorial ↔ horizontal, rectangular ↔ spherical) and stereographic map projections (general, north pole, south pole) along with polar-to-window and perspective-to-window screen space mappings. Reusable for any application requiring spherical coordinate transformations or stereographic projection.
Implements multiple line drawing algorithms for terminal graphics: ASCII lines with slope characters, smooth Unicode lines using box-drawing characters, dotted lines, and a novel Braille-based line renderer that packs dots into Braille cells for higher resolution. Also includes an ellipse drawing algorithm. These functions operate on ncurses windows and are moderately coupled but could be extracted with minor effort.
Provides a cross-platform high-resolution timer abstraction supporting Windows (QueryPerformanceCounter), macOS (clock_gettime_nsec_np), POSIX (clock_gettime), and fallback gettimeofday. Wraps timestamp acquisition, difference calculation (microseconds), and sleep. This is a clean, portable utility that can be reused in any performance-sensitive C project.