4
$\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 at 23:40
3
$\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$
1
  • 1
    $\begingroup$ Very helpful, thanks! I chose Roman's C implementation link, did extensive testing and it worked perfectly! $\endgroup$ – Ricardo Jan 28 at 1:19
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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.