Instantly share code, notes, and snippets.

Last active October 23, 2019 22:48
Moon Phase

This is an example of using D3's orthograph projections to visualize moon phases. My starting point for this was http://bl.ocks.org/mbostock/3795040.

## GeoJSON

There is a nice geojson wsyiwig editor here: http://geojson.io/#map=1/16/-68.

When defining points, the first value is the angle in degrees from the prime meridian (-180, 180). The second is the angle in degrees from the equator [-90, 90]. So, any value [x, 90] is at the North pole, and any value [x, -90] is at the south pole. I was getting some funkiness when I put things directly on the poles, so I fudged it a little bit and went with 89.5.

You can read hemisphere.json like this:

1. [90, -90] -- start at the south pole ([x, -90]), 1/4 of the way around travelling east from the prime meridian ([90, x]).
2. [90, 90] -- Go to the north pole ([x, 90])
3. [-90, 90] -- Travel halfway around the world, so you're 3/4 of the way past the prime meridian, or 1/4 of the way if you travel west ([-90, x])
4. [-90, -90] -- Go back to the south pole
5. [90, -90] -- Travel back to the starting point

It's important to have your first point and last point be identical, or nothing will render.