Plan 9 from Bell Labs’s /usr/web/sources/contrib/axel/globe/globeangle.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>

/*
 * globe.c - calculate the rotation of
 * the earth as viewed from the sun
 *
 * usage: 
 *      map orthographic -o `{globe} | plot
 */
void
main()
{
        enum {
                declination = 23.47,
                degperhour = 15.0
        };
        Tm*tm;
        double roll, pitch, yaw;

        tm = gmtime(time(nil));
        roll = -(cos((tm->yday+284) * PI/182.5)) * declination;
        pitch = (sin((tm->yday+284) * PI/182.5)) * declination;
        yaw = (tm->hour+ (tm->min/60.0) -12) * degperhour;

        print("%f %f %f\n", pitch, yaw, roll);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].