Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your code is hard to follow, but I'll try to get you some tips:</p> <ul> <li>There are existing libraries out there that compute solar angle/azimuth and sunrise/sunset for a given date. Use google as a help, here's some relevant resources: <a href="http://www.esrl.noaa.gov/gmd/grad/solcalc/" rel="nofollow">http://www.esrl.noaa.gov/gmd/grad/solcalc/</a> If you don't find any useful source code, I could post some.</li> <li>Do not use double to calculate with dates and times. That's confusing and results in errors. Use a data type that is intended to store dates. </li> <li><p>For your code, you say that the time is running to fast. Since referenceTime and day in the last line are constant (at least for half a day), the error must be in proportion. I think you're mixing to many cases there. The interpolation should go from the start of the range to the end, so in the case</p> <p>proportion = (distanceAlong - previousDayEvening) / (closestDayMorning - previousDayEvening); referenceTime = previousDay + day * 3 / 4;</p></li> </ul> <p>proportion should run from (previousDay + day * 3 / 4) to (closestDay + day * 3 / 4), or, described differently, from the dusk to dawn of closestDay. But it's completely unclear how this interpolation should work. </p> <p>Try to draw a diagram of the different cases (I believe there should only be two, one for day and one for night) and the corresponding interpolation. </p> <p>But: What are you trying to achieve after all? The resulting time is just a forward running time, it is actually independent of latitude or longitude or time of day. So to make the time run, you don't need to know where the sun is. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload