Helper function to calculate the sun's position at a given time and position on the earth.
SunPosition( &Float:Elevation, &Float:Azimuth, Float:Lat, Float:Lng, time )
The function calculates the sun's position (Elevation & Azimuth) at the given lat/long coordinate at the given time.
The function does not compensate for altitude, but assumes sea level.
Elevation | Variable to receive the result elevation in meters |
Azimuth | Variable to receive the result azimuth in degrees |
Lat | Latitude in degrees |
Lng | Longitude in degrees |
time | UTC time as seconds since epoch (unixtime) |
If Lat/Lng and time are not submitted, the current GPS position and current time is assumed
The function does not return a value, but sets the Elevation and Azimuth variables.
new Float:el; new Float:az; SunPosition( el, az, 38.67, -121.15, 1597439230 ); // Sun position in Folsom, CA on August 14 2020 @ 14:07 local time (21:07 UTC) // el = 62.2 degrees, az = 211.4 degrees (rounded) // Using GPS/current time as defaults, omitting location and time parameters: SunPosition( el, az );