Search code examples
time3dastronomy

Orient a real sky sphere with given time and geographic coordinate


I found nice sky texture from the NASA site and plan to use it as sky sphere which is working quite well.

But now I would like to correctly orient this sphere to match reality but i don't know how to proceed.

My first guess was to use earth orientation (via sidereal time) but it doesn't help me that much to orientate the sky sphere.

Is there any algorithm / reference / similar which can help me to solve this problem ?


Solution

  • Assuming that your sky sphere is tilted the same as the globe (i.e. at ~23.5') so that their "vertical north/south" axes are aligned then sidereal time should be all you need to know, and that'll tell you how far the sky sphere should be rotated around that titled axis relative to 0' longitude.

    I use this (JavaScript) function to calculate the Greenwich Mean Sidereal Time:

    function GMST(t) {
        t = t || +new Date();
    
        var epoch = Date.UTC(2000, 0, 1, 12, 0, 0, 0);
    
        // days after the epoch
        var d = (t - epoch) / 86400000;
    
        return mod(18.697374558 + 24.06570982441908 * d, 24);
    };
    
    // ensures negative numbers generate "correct" modulo results
    function mod(m, n) {
        return ((m % n) + n) % n;
    };