#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);
}
|