transit.frink

Download or view transit.frink in plain text format


// This program animates the transit of Venus across the sun on 2012-06-05.

use planets.frink
use sun.frink

timezone = "Mountain"
lat = 39.58560 degrees North
long = 104.89598 degrees West

/*lat = DMS[40, 33, 35.84]  North
long = DMS[105,04,57.64]  West*/



df = ### yyyy-MM-dd-HH:mm ###

g = new graphics
win = g.show[]

//for planet = [Planet.Mercury, Planet.Venus]
planet = Planet.Venus
startdate = #2012-06-05 04:00 PM#
enddate = sunset[startdate, lat, long]
for d = #2012-06-05 04:00 PM# to enddate step 10 s
{
   [azsun, altsun] = refractedSunAzimuthAltitude[d, lat, long]
   [azp, altp]     = planet.refractedAzimuthAltitude[d, lat, long]

   separation = angularSeparation[azsun, altsun, azp, altp]

   sunRadius =   sunRadiusAngle[d]
   venusRadius = planet.radiusAngle[d]
   //println[venusRadius -> [0, "deg", "arcmin", "arcsec"]]

   flag = ""
   if separation < sunRadius + venusRadius
   {
      flag = "*"
      
      if separation < sunRadius - venusRadius
         flag = "**"

      g = new graphics
      [skyr,skyg,skyb] = skyDarkness[d, lat, long, [[.1,.1,.1], [.1,.1,.2], [.1,.1,.3], [.1,.1,.4], [.8,.8,1]]]
      g.backgroundColor[skyr, skyg, skyb]

      // Draw the sun
      g.color[1,1,0]  // Yellow
      g.fillEllipseCenter[(azsun-azsun) cos[-altsun], -(altsun-altsun), 2 sunRadius, 2 sunRadius]

      // Draw Venus
      // How much more black could it be?  The answer is none.  None more black.
      g.color[0,0,0]
      g.fillEllipseCenter[(azp-azsun) cos[-altp], -(altp-altsun), 2 venusRadius, 2 venusRadius]
//      g.add[planet.drawPolygonRelativeToZenith[d, lat, long, azp, -altp, venusRadius, true]]
      win.replaceGraphics[g]
   }
   
   println[(d->timezone) + "\t" + format[separation,"deg", 5] + "\t$flag" ]
}


Download or view transit.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 20145 days, 6 hours, 18 minutes ago.