Published
Edited
Sep 14, 2018
4 stars
Insert cell
Insert cell
Insert cell
geoPolyhedralMurphey = function() {
const raw = d3.geoAzimuthalEqualAreaRaw;

function clipPole(lambda, phi) {
// approximation of the distance (in radians) to the ±80° circle
let pole = abs(phi) - 1 * lambda ** 2 - 0.78;
if (pole > 0) phi -= sign(phi) * pole;
return raw(lambda, phi);
}
clipPole.invert = raw.invert;

function faceProjection(face) {
return d3.geoProjection(clipPole).rotate([-face.site[0], -face.site[1]]);
}

return d3
.geoPolyhedralVoronoi()
.parents([-1, 0, 0, 1, 0, 4, 4, 5])
.angle(30)
.polygons(polygons)
.faceProjection(faceProjection)
.fitExtent([[0, 0], [width, width / 2]], { type: "Sphere" })
.rotate([35, 0])
.precision(0.1);
}
Insert cell
function octant(face) {
let poly = [];
let j = face.length - 1;
const N = 16;
for (let i = 0; i < face.length; i++, j = ++j % face.length) {
const interpolate = d3.geoInterpolate(face[j], face[i]);
let n;
for (n = 0; n <= N / 2; n++) poly.push(interpolate((0.1 + n) / (N + 1)));
poly.push(interpolate(0.499)); // anchor points
poly.push(interpolate(0.501));
for (n = n; n < N; n++) poly.push(interpolate((0.1 + n) / (N + 1)));
}
poly.push(poly[0]);
return { type: "Polygon", coordinates: [poly], face: face };
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more