d3.geo.hexakisIcosahedron = (function () { 'use strict'; var Y = Math.atan2(1, 2) * 180 / Math.PI; var I = d3.geo.interpolate([0, Y], [72, Y])(0.5); var Y4 = (90 + Y) / 2; var Y3 = d3.geo.interpolate(I, [36, 90])(0.36)[1]; var Y2 = I[1]; var Y0 = d3.geo.interpolate(I, [36, -Y])(0.36)[1]; function icosahedronPoints() { var points = []; points.push([0, -90]); for (var x = 0; x < 360; x += 72) { points.push([x, -Y], [x + 36, Y]); } points.push([0, 90]); return {type: 'MultiPoint', coordinates: points}; } function hexakisCenterPoints() { var points = []; for (var x = 0; x < 360; x += 72) { points.push( [x + 36, -Y3], [x, Y0], [x + 72, Y3], [x + 72 + 36, -Y0] ); } return {type: 'MultiPoint', coordinates: points}; } function hexakisCrossPoints() { var points = []; for (var x = 0; x < 360; x += 72) { points.push( [x, -Y4], [x, Y2], [x + 18, 0], [x + 36, Y4], [x + 36, -Y2], [x + 36 + 18, 0] ); } return {type: 'MultiPoint', coordinates: points}; } function icosahedronEdges() { var edges = []; for (var x = 0; x < 360; x += 72) { edges.push([[x, -90], [x, -Y]]); edges.push([[x, -Y], [x + 72, -Y]]); edges.push([[x + 36, Y], [x - 36, Y]]); edges.push([[x + 36, Y], [x, -Y]]); edges.push([[x - 36, Y], [x, -Y]]); edges.push([[x + 36, 90], [x + 36, Y]]); } return {type: 'MultiLineString', coordinates: edges}; } function hexakisCenterEdges() { var edges = []; for (var x = 0; x < 360; x += 72) { edges.push([[x, -90], [x + 36, -Y3]]); edges.push([[x, -Y], [x + 36, -Y3]]); edges.push([[x + 72, -Y], [x + 36, -Y3]]); edges.push([[x + 36, Y], [x + 36, -Y0]]); edges.push([[x, -Y], [x + 36, -Y0]]); edges.push([[x + 72, -Y], [x + 36, -Y0]]); edges.push([[x + 36, Y], [x, Y0]]); edges.push([[x - 36, Y], [x, Y0]]); edges.push([[x, -Y], [x, Y0]]); edges.push([[x, 90], [x, Y3]]); edges.push([[x + 36, Y], [x, Y3]]); edges.push([[x - 36, Y], [x, Y3]]); } return {type: 'MultiLineString', coordinates: edges}; } function hexakisSideEdges() { var edges = []; for (var x = 0; x < 360; x += 72) { edges.push([[x, Y3], [x, Y0]]); edges.push([[x - 36, -Y0], [x, Y0]]); edges.push([[x + 36, -Y0], [x, Y0]]); edges.push([[x + 36, -Y0], [x + 36, -Y3]]); edges.push([[x - 36, -Y3], [x + 36, -Y3]]); edges.push([[x, Y3], [x + 72, Y3]]); } return {type: 'MultiLineString', coordinates: edges}; } return { icosahedronPoints: icosahedronPoints, icosahedronEdges: icosahedronEdges, hexakisCenterPoints: hexakisCenterPoints, hexakisCenterEdges: hexakisCenterEdges, hexakisCrossPoints: hexakisCrossPoints, hexakisSideEdges: hexakisSideEdges }; })();