Open maateusx opened 5 years ago
font: http://www.voidware.com/moon_phase.htm
`int moon_phase(int y, int m, int d) { //calculates the moon phase (0-7), accurate to 1 segment. //0 = > new moon. //4 => full moon.
int c,e;
double jd;
int b;
if (m < 3) {
y--;
m += 12;
}
++m;
c = 365.25*y;
e = 30.6*m;
jd = c+e+d-694039.09; /* jd is total days elapsed */
jd /= 29.53; /* divide by the moon cycle (29.53 days) */
b = jd; /* int(jd) -> b, take integer part of jd */
jd -= b; /* subtract integer part to leave fractional part of original jd */
b = jd*8 + 0.5; /* scale fraction from 0-8 and round by adding 0.5 */
b = b & 7; /* 0 and 8 are the same so turn 8 into 0 */
return b;
`int Moon_phase(int year,int month,int day) { //Calculates the moon phase (0-7), accurate to 1 segment. //0 = > new moon. //4 => Full moon.
int g, e;
if (month == 1) --day;
else if (month == 2) day += 30;
else // m >= 3
{
day += 28 + (month-2)*3059/100;
// adjust for leap years
if (!(year & 3)) ++day;
if ((year%100) == 0) --day;
}
g = (year-1900)%19 + 1;
e = (11*g + 18) % 30;
if ((e == 25 && g > 11) || e == 24) e++;
return ((((e + day)*6+11)%177)/22 & 7);
}`
both formulae are simplified to work from 1900 to 2199 inclusive. however, ive discovered that they disagree. consider september 23, 2002. the second formula claims this a full moon, the first does not. the moon is not full on this night so the first seems more accurate. here is a command line pc program that is more accurate than the above for reference.
http://www.ben-daglish.net/moon.shtml
function Trig2(year,month,day) { n = Math.floor(12.37 * (year -1900 + ((1.0 * month - 0.5)/12.0))); RAD = 3.14159265/180.0; t = n / 1236.85; t2 = t * t; as = 359.2242 + 29.105356 * n; am = 306.0253 + 385.816918 * n + 0.010730 * t2; xtra = 0.75933 + 1.53058868 * n + ((1.178e-4) - (1.55e-7) * t) * t2; xtra += (0.1734 - 3.93e-4 * t) * Math.sin(RAD * as) - 0.4068 * Math.sin(RAD * am); i = (xtra > 0.0 ? Math.floor(xtra) : Math.ceil(xtra - 1.0)); j1 = julday(year,month,day); jd = (2415020 + 28 * n) + i; return (j1-jd + 30)%30; }
https://stellafane.org/misc/equinox.html
`<!DOCTYPE html>
This page will calculate when the Equinoxes and Solstices are for a given year. Type in a year or use the buttons to step forward and backward year-by-year:
Also see our Moon Phase Calculator
TIME ACCURACY: The calculated times are in Terrestrial Dynamical Time (TDT or TT), a replacement for Ephemeris Times (ET). Meeus claims the error is less than one minute for the years 1951-2050 for these calculations (the errors increase as you move farther away from these dates).
CIVIL TIME: TDT is a uniform time used for astronomical calculations. Civil time, such as UTC (popularly known as GMT, but technically incorrect) or your local time, is corrected for the non-linear changes in the rotation of the earth. This is done accurately only through observations. This web page corrects the the calculated TDT to civil time using a table of observations from 1620 thru 2002. Time corrections outside this range are estimated from predictive equations. See Meeus' book for additional details.
LOCAL TIME: Local time zone conversion is done by the JavaScript built-in runtime functions from the corrected UTC (including daylight or summer time rules), based on information it gets from your computer's environment settings. If the local time is in the wrong time zone for you, you need to check and adjust these settings on your computer, there is nothing in this web page or the code behind it to change this. On Windows machines, right click on the clock in the task bar and select "Adjust Date/Time", and then click the "Time Zone" tab.
CREDITS: The algorithms and correction tables for this computation come directly from the book Astronomical Algorithms Second Edition by Jean Meeus, ©1998, published by Willmann-Bell, Inc., Richmond, VA, ISBN 0-943396-61-1. They were coded in JavaScript and built into this web page by the web page author, Ken Slater.
CAUTION: While the output has been spot checked for correctness against known tables, the code has not been thoroughly tested and could contain errors. The underlying algorithms are not exact and times could vary by several minutes. Consult the book credited above for detailed information. Note also that the day-of-week will not be correct when the date is in the Julian calendar (earlier than 1582-Oct-15).
Solstices and Equinoxes algorithm
Task
Feriados
Saida de Dados