moonPlanetPlot.frink

View or download moonPlanetPlot.frink in plain text format


/*  This program plots the approach of a planet and the moon.
    Note that moon alignments are sensitive to parallax, so the exact location
    on the earth is important.
*/


use planets.frink

// Configure your location and timezone here
lat = 40 degrees North
long = 105 degrees West
timezone = "America/Denver"  // You can replace this with timezone = timezone[]

planet = Planet.Jupiter

g = new graphics

//g.backgroundColor[.5, .5, 1]
g.font["SansSerif", 0.06 degree]
outFormat = ### HH:mm ###   // Format for displaying times on the graph

for date = #2015-10-09# to #2015-10-10# step 10 minutes
{
   planetRadius = Planet.Earth.radiusAngle[date, planet]
   moonRadius = moonRadiusAngle[date]

//   println["Moon radius is " + format[moonRadius, "degrees", 4]]

   [moonAz, moonAlt] = refractedMoonAzimuthAltitude[date, lat, long]
   if moonAlt > 0 deg
      g.add[drawMoonPolygonRelativeToZenith[date, lat, long, 0 deg, 0 deg, moonRadius, true]]
   
   [planetAz, planetAlt] = planet.refractedAzimuthAltitude[date, lat, long]

   // Only show positions while the planet is above the horizon
   if planetAlt > 0 deg
   {
      // Draw planet position relative to a semi-fixed moon.
      relAz = planetAz-moonAz
      relAlt = planetAlt-moonAlt
      g.add[Planet.Venus.drawPolygonRelativeToZenith[date, lat, long, relAz, -relAlt, planetRadius, true]]
      angle = arctan[relAlt, relAz]
      g.text[date -> [outFormat, timezone], relAz, -relAlt, "left", "center", angle]
   }
   
   sep = angularSeparation[moonAz, moonAlt, planetAz, planetAlt]
   println[(date->timezone) + ": Separation is " + format[sep, "degrees", 4]]
}
   
g.show[]

g.write[planet.getName[] + ".svg",1000,700]
g.write[planet.getName[] + ".html",1000,700]


View or download moonPlanetPlot.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 17645 days, 8 hours, 31 minutes ago.