5
$\begingroup$

Given its right ascension and declination, find out the constellation a celestial body is in.

Does anyone know of an algorithm (C#, js) for that?

It would read the constellation boundaries (e.g. constellations.bounds.json, at https://github.com/ofrohn/d3-celestial/tree/master/data) and figure the constellation out.

Thanks in advance!

$\endgroup$
1
  • $\begingroup$ I think there is a good chance such an algorithm in those (or similar) languages have been posted before, but it may take some hunting to find them. $\endgroup$
    – uhoh
    Jan 24, 2021 at 23:40

2 Answers 2

4
$\begingroup$

If the coordinates are precessed to epoch B1875.0, the constellation boundaries lie neatly along the equatorial coordinate grid, allowing simpler tests against boundary segments.

Roman 1987 describes a basic algorithm and provides implementations in C and F77.

Glaschke 2010 makes a binary partition of the sky for fast lookup and provides an implementation in C.

Skyfield implements another fast lookup in Python, using lists sorted by right ascension and by declination. It builds its data structure in build_constellations.py and uses it in constellationlib.py.

$\endgroup$
4
1
$\begingroup$

I realized it's the problem of checking whether a point is inside a spherical polygon or not. See e.g. https://github.com/LeoAlexandrov/Spherical.

But I recommend Roman's implementation, much shorter and simpler (see the accepted answer).

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .