using a cosinus trick to handle day/night