aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / ui / sky_real.h
| 1 | /* sky_real.h -- the real sky behind Allen: the catalogue's stars at their |
| 2 | * true places, brightness and colour; the Milky Way from Gaia DR3 source |
| 3 | * counts and integrated G-band flux (ESA/Gaia/DPAC, CC BY-NC 3.0 IGO), |
| 4 | * reddened by extinction from gaiadr3.astrophysical_parameters; the |
| 5 | * galaxies the eye can see. The data are in sky_data.c (generated, see |
| 6 | * sky_data.h); this is the drawing, integer only. |
| 7 | * |
| 8 | * The view: a gnomonic projection (what a pinhole camera sees) of any piece |
| 9 | * of sky, the view centre at (cx, cy) on the screen, a set width of sky |
| 10 | * across the screen's width. |
| 11 | * |
| 12 | * The Milky Way is stored as a full-sphere equirectangular grid; rendering |
| 13 | * inverse-projects each screen point to (RA, Dec) and bilinear-samples the |
| 14 | * grid, so any view can be shown. |
| 15 | * |
| 16 | * Also here: the sidereal-time maths for "the sky above you now". */ |
| 17 | #ifndef AIENOS_SKY_REAL_H |
| 18 | #define AIENOS_SKY_REAL_H |
| 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "night.h" |
| 22 | #include "sky_data.h" |
| 23 | |
| 24 | /* Where the direction d (Q15) lands on a screen w px wide whose view |
| 25 | * centre is at (cx, cy) px: (x16, y16) in 16ths of a pixel, the pixel i |
| 26 | * spanning 16 i to 16 i + 16. 0 if it is more than 88 degrees from the |
| 27 | * centre (behind the camera), else 1. */ |
| 28 | int ck_sky_project(const ck_sky_view *v, const int16_t d[3], int32_t w, int32_t cx, int32_t cy, int32_t *x16, |
| 29 | int32_t *y16); |
| 30 | |
| 31 | /* Inverse-project and sample the sourced Milky Way at every native pixel |
| 32 | * centre, then encode sRGB with ordered quantization. No screen-grid |
| 33 | * intermediate, runtime blur or enlargement. The Gaia-derived map has |
| 34 | * 360 x 180 angular luma cells (stored 361 x 180 with a wrap column) and |
| 35 | * 181 x 90 stored chroma samples. Native pixels cannot invent source detail. */ |
| 36 | void ck_sky_draw_milkyway(ck_canvas *cv, int32_t cx, int32_t cy, const ck_sky_view *v); |
| 37 | |
| 38 | /* Draws every catalogue star in the view into cv (a w x h sky whose view |
| 39 | * centre is at (cx, cy)). UI scale does not affect a point source. |
| 40 | * Adds linear light with at most 2 x 2 native-pixel support. The brightest |
| 41 | * few (V <= 1.0) are also listed in tw, up to max, to twinkle; *ntw: count. */ |
| 42 | void ck_sky_draw_stars(ck_canvas *cv, int32_t cx, int32_t cy, const ck_sky_view *v, |
| 43 | ck_night_star *tw, unsigned max, unsigned *ntw); |
| 44 | /* Dynamic light uses exactly the static point source's native footprint. |
| 45 | * amount is additional linear light in 1/256 of its catalogue flux. */ |
| 46 | void ck_sky_twinkle(ck_canvas *cv, const ck_rect *clip, const ck_night_star *s, uint32_t amount); |
| 47 | |
| 48 | /* The largest box galaxy i can need on a w-wide screen (for memory). */ |
| 49 | ck_rect ck_sky_galaxy_bound(uint32_t w, unsigned i); |
| 50 | /* Galaxy i's box on a w x h screen, view v, centre (cx, cy) (clipped; empty |
| 51 | * if not in the view or no galaxy i). */ |
| 52 | ck_rect ck_sky_galaxy_box(uint32_t w, uint32_t h, int32_t cx, int32_t cy, const ck_sky_view *v, unsigned i); |
| 53 | /* Fills g->light and g->phase over g->box. */ |
| 54 | void ck_sky_galaxy_maps(ck_night_galaxy *g, unsigned i, uint32_t w, int32_t cx, int32_t cy, |
| 55 | const ck_sky_view *v); |
| 56 | |
| 57 | /* ---- the sky above you now ---- */ |
| 58 | |
| 59 | /* Greenwich mean sidereal time at unix time t (seconds, UTC taken as UT1: |
| 60 | * within a second), in turns / 2^32. IAU 1982 (Aoki et al. 1982; USNO). */ |
| 61 | uint32_t ck_sky_gmst(int64_t unix_s); |
| 62 | /* The direction straight up (the zenith) at unix time t from latitude lat |
| 63 | * and east longitude lon (millionths of a degree), in J2000 axes (the |
| 64 | * local sidereal time, then the 1976 IAU precession back to J2000), Q15. |
| 65 | * As RA and Dec in millionths of a degree too, if ra or dec are given. */ |
| 66 | void ck_sky_zenith(int64_t unix_s, int32_t lat_udeg, int32_t lon_udeg, int16_t d[3], int32_t *ra_udeg, |
| 67 | int32_t *dec_udeg); |
| 68 | /* A view centred on (ra, dec) (millionths of a degree), fov degrees wide |
| 69 | * (thousandths), north up turned by roll (thousandths), built with integer |
| 70 | * trigonometry. */ |
| 71 | void ck_sky_view_at(ck_sky_view *v, int32_t ra_udeg, int32_t dec_udeg, int32_t fov_mdeg, int32_t roll_mdeg); |
| 72 | |
| 73 | /* the location setting: unset unless the build sets both (millionths of a degree) */ |
| 74 | #if defined(CK_SKY_LAT_UDEG) && defined(CK_SKY_LON_UDEG) |
| 75 | #define CK_SKY_HAVE_LOCATION 1 |
| 76 | #else |
| 77 | #define CK_SKY_HAVE_LOCATION 0 |
| 78 | #endif |
| 79 | #endif |