Src files for moon/sun current constellation?

  • John Doisneau
    John Doisneau

    Hello, this message is destined to developers who know well the Stellarium

    I basically would like to know which source files and functions I could reuse
    to find in which one of the 12 constellations the moon and the sun are, at a
    given time, and at a given location (lat,lon,alt).

    I would really appreciate it if a willing developer could help me, as I am
    quite lost in the source after having downloaded the current trunk...

    Thank you in advance!

  • barrykgerdes

    The constellation lines depend on the culture and details of these are in sky
    cultures section.
    The other information is calculated from data in the ssystem.ini file using
    the standard astronomical algorithms.
    To find the location of any of the items from stellarium you just need to
    enter the date-time and location of interest and select the item required from
    the find menu. The constellation lines and boundaries can then be selected
    from the main menu but will depend on the sky culture.

    However the information will be relevant to the science of astronomy and some
    folk law and may bear little relationship to astrology or religious calendars.
    For this you can write your own sky culture to draw constellation lines
    anywhere you wish.


  • John Doisneau
    John Doisneau

    Thank you very much Barry - your reply was insightful.

    OK, I got you regarding the sky cultures - in fact, I should have precised
    that what mattered to me was in which constellation of the zodiac the sun
    and the moon are, at a given time and place. Doing my homework, I found that I
    had to use the Western culture, so that's OK.

    Now, about the computation, I'd like to calculate this programmatically rather
    than using the full Stellarium app, so I need a bit more details... I saw that
    ssystem.ini has the sun and moon objects defined - great. Where I need more of
    your time, if you could, is to help me find the function (or sequence of
    functions) I need to call in order to find out the sun and moon's current
    zodiac constellation, given an earth location (lat, lon, alt), using the
    standard astronomical algorithms you mentioned.

    Thank you!

  • barrykgerdes

    The information used to make the calculations of the sky are all contained in
    the src folder of stellarium. If you understand C, C++ programing you should
    be able to extract the information you need. There is no one source.

    If you are not a programmer you will need to learn how. A good book on how to
    make astronomical calculations is Astronomy with your Personal Computer by
    Peter Duffet-Smith. All the algiorithms needed are explained with examples
    written in BASIC. However as I said earlier due to precession the Zodiacal
    calendar is about 2000 years out of date compared to the astronomical calendar
    and all the algorithms are for the astronomical calendar.

    If you search the internet you may be able to find a program already written
    that will satisfy your needs


  • John Doisneau
    John Doisneau

    Hi Barry, thanks - I am a programmer, and I was just trying to get a jump
    start because I saw that the code of Stellarium has many files... I have
    downloaded all the source code, and I am about to be able to compile it under
    Windows using Mingw... I may even contribute to the project and develop a

    I do not understand what you wanted to say when you wrote that the Zodiacal
    calendar is 2000 years old - in fact, I do not have any interest in the
    Zodiacal calendar, I just have interest in the Zodiacal constellations. As
    explained, I am trying to find the pieces of code that will allow me to find
    out the Zodiacal position of the sun and the moon at a given date/time and at
    a given location on earth (lat, lon, alt). Any hint very well appreciated!

  • barrykgerdes

    I wrote a program many years ago that calculated the position of the Sun, Moon
    and Planets. It also used a data base containing the coords of the western
    constellations. This data base was also used to list the constellation the
    object was currently in. I don't have the program any more but it used many
    sub routines to make all the calculations using the algorithms from the book I
    referred to above.


  • John Doisneau
    John Doisneau

    OK Barry, thank you, even if your comments do not help me much with
    Stellarium's code, at least you have told me about that reference book. Unless
    another developer helps me I will have to spend a large amount of time to
    decrypt Stellarium's source, but that's OK...

  • Kird

    You don't need the accuracy of the routines used in Stellarium for that kind
    of application. You can use routines from 'Astronomy on the Personal

    Download the file '' under 'Pascal source codes (zip, 130 kB)'.
    These are from previous editions. The source code in the 4th edition is
    written in C. Find the files minisun.pas and minimoon.pas. The coördinates
    from these routines are accurate enough to predict rise and set times.

    Constellation boundaries:

    Note that during the first half of december, the sun is in Ophiuchus. You will
    need 13 constellations.

    Good luck,


  • John Doisneau
    John Doisneau

    Thank you very much Hendrik. To the point. Exactly what I needed!

  • qam1

    See the newest version of my rise and set script

    It calculates the current constellation the sun, moon and planets are in.

    It only does the constellations near the Ecliptic (13 Zodiac, Auriga, Cetus,
    Orion, Sextans) as such it's not good for Plutoids or the asteroids that drift
    far out of the ecliptic band.

    You can see the source in the script file


  • Anonymous

    Thank you so much, qam1! This is all I could hope for, and it replies exactly to my question. You basically did all the work for me! Take care!



Cancel   Add attachments