// Persistence of Vision Ray Tracer Scene Include File // File: sunpos.inc // Desc: This macro returns the suns position, // on a given date, time, and location on earth. // Date: 15-09-1998 // Updated : 2001-07-27 // Auth: Ingo Janssen // #ifndef(SunPos_Inc_Temp) #declare SunPos_Inc_Temp=version; #version 3.5; // // ====================================================== // // Assumption: in the scene north is in the +Z direction, south is -Z. // // Invoke in your scene: // light_source { // SunPos(Year, Month, Day, Hour, Minute, Lstm, LAT, LONG) // rgb 1 // } // // Greenwich, noon on the longest day of 2000 (no daylight saving): // SunPos(2000, 6, 21, 12, 2, 0, 51.4667, 0.00) // // Year: in four digits // Month: number // Dat: number // Time: in 24 hour format // Lstm: Meridian of your local timezone (+1 hour = +15 deg) // in degrees (east = positive, west = negative) // Location on earth: // LAT: Lattitude in degrees.decimal, northern hemisphere = positive, southern = negative // LONG: Longitude in degrees.decimal, east = positive, west is negative // // The macro returns the position of the sun, but also declares it as the vector SolarPosition. // Also the found Azimuth (Az) and Altitude (Al) are declared, this can be usefull for // aligning an object with the sunlight: cylinder{ // <-2,0,0>,<2,0,0>,0.1 // rotate <0, Az-90, Al> // texture {.. LightRay ..} // } // // ====================================================== // // Find your local position at http://gnpswww.nima.mil/geonames/GNS/ (Gazetteer search) // // Local time(zone) at http://www.hilink.com.au/times/ // // Equations used here can be found at http://hotel04.ausys.se/pausch/english.htm (Computing rise/set times) // not only for the sun but also for the moon, planets and other stuff up there. // // ====================================================== // #macro SunPos(Year, Month, Day, Hour, Minute, Lstm, LAT, LONG) #if (abs(LONG-Lstm)>30) #debug "\nREMARK: \nLongitude differs by more than 30 degrees from timezone meridian.\n" #debug concat("Local timezone meridian is:",str(Lstm,5,0),"\n") #debug concat("Longitude is:",str(LONG,5,0),"\n") #end // Calculate universal time (UT) #local T= Hour+(Minute/60); #local UT= T-Lstm/15; #if (0>UT) #local Day= Day-1; #local UT= 24+UT; #end #if (UT>24) #local Day= Day+1; #local UT= UT-24; #end // Amount of days to, or from, the year 2000 #local d= 367*Year-int((7*int((Year+int((Month+9))/12)))/4)+int((275*Month)/9)+Day-730530+UT/24; // Longitude of perihelion (w), eccentricity (e) #local w= 282.9404+4.70935E-5*d; #local e= 0.016709-1.151E-9*d; // Mean anomaly (M), sun's mean longitude (L) #local M= 356.0470+0.9856002585*d; #if (0,<-Al,Az,0>); (SolarPosition) #end #version SunPos_Inc_Temp; #end