perihelion.frink

Download or view perihelion.frink in plain text format

// Calculates perihelion time of Earth from the sun.

use sun.frink
use planets.frink
use binarySearch.frink

mindist = 2 au
maxdist = 0 au

starttime =  beginningOfYear[now[]]
endtime =    starttime + 365 days
println["starttime is $starttime"]
println["endtime is $endtime"]


f = {|date| Planet.Earth.getCoordinates[date]@2}

[mintime, mindist] = findALocalMinimum[f, starttime, endtime, 1 s]
[maxtime, maxdist] = findALocalMaximum[f, starttime, endtime, 1 s]

println["Minimum distance is " + (mindist -> "km") + ", " + (mindist -> "au") + ", " + (mindist-> "miles") + " at $mintime."]
println["Maximum distance is " + (maxdist -> "km") + ", " + (maxdist -> "au") + ", " + (maxdist-> "miles") + " at $maxtime."]


Download or view perihelion.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19346 days, 22 hours, 46 minutes ago.