This is a very reduced version of Vladimir Agafonkin's SunCalc library (https://github.com/mourner/suncalc).
A clone for shadow calculation of OSM Buildings. Contains code from getPosition() only.
--
SunCalc is a tiny BSD-licensed JavaScript library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time, created by Vladimir Agafonkin (@mourner) as a part of the SunCalc.net project.
Most calculations are based on the formulas given in the excellent Astronomy Answers articles about position of the sun and the planets. You can read about different twilight phases calculated by SunCalc in the Twilight article on Wikipedia.
suncalc(timeAndDate, latitude, longitude)
Returns an object with the following properties:
altitude
: sun altitude above the horizon in radians, e.g.0
at the horizon andPI/2
at the zenith (straight over your head)azimuth
: sun azimuth in radians (direction along the horizon, measured from south to west), e.g.0
is south andMath.PI * 3/4
is northwest