/** Program to test this interesting tweet:
https://twitter.com/isislovecruft/status/1693836333226336453
"what is your favourite celestial navigation fact?
"i’ll start: drawing a line connecting the two points of a crescent moon
points to true south in the northern hemisphere and points to true north
in the southern hemisphere"
The result is that this statement is only approximately correct. The
angle between the points and true north/south oscillates somewhat strongly
around zero degrees, but with a rather large typical amplitude error of
20-25 degrees, which goes to 90 degrees at times. The RMS error in the
original statement is about 22.7 degrees, as found by this program.
Result tweet:
https://twitter.com/Frinklang/status/1694626851669540918
See the following graphs (which are produced by this program):
https://futureboy.us/temp/nav.svg
https://futureboy.us/temp/nav.html
https://futureboy.us/temp/nav.png
*/
use sun.frink
use Grid.frink
start = beginningOfYear[now[]]
end = beginningOfYearPlus[now[], 1]
g = new graphics
p = new polyline
points = 0
sum = 0 deg^2
for d = start to end step hour
{
points = points + 1
a = moonPositionAngle[d]
a1 = abs[a] - (90 deg)
sum = sum + a1^2
p.addPoint[MJD[d]-MJD[start], a1]
println["$d\t" + (a -> degrees)]
}
RMS = sqrt[sum/points]
println["RMS is " + format[RMS, "deg", 3]]
g.add[p]
// Add semi-automatic grid lines to the graph
grid = new Grid
grid.setUnits[day, degree]
grid.auto[g]
g.add[grid.getGrid[]]
// Draw horizontal red line indicating where the original tweet
// is correct.
g.color[1,0,0,.5]
g.line[0 day, 0 deg, 365 day, 0 deg]
g.show[]
g.write["nav.png", 1000,800]
g.write["nav.svg", 1000,800]
g.write["nav.html", 1000,800]