// Astronomical computations (sun direction) // Last edited on 2005-08-28 14:47:50 by stolfi #macro compute_sun_direction(latitude, season, hour) // Direction of sun in heliocentric system: #local d0 = vrotate(<1,0,0>,season*360*z); // Direction of sun in global geocentric system (Z = Earth axis) #local d1 = vrotate(d0, -23*x); // Direction of sun at noon in geocentric system of local meridian: #local d2 = vrotate(d1, -season*360*z); // Direction of sun at the given hour, same system: #local d3 = vrotate(d2, -360*(hour-12)/24*z); // Ditto, local geographic system: #local d4 = vrotate(d3, latitude*y); // Change axes (Z = up, Y = North, X = East): < d4.y, d4.z, d4.x > #end