Published
Edited
May 28, 2020
Importers
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// map a sphere octant to the Reuleaux triangle
function reuleauxRaw() {
// r is the radius of the circle centered on the pole and extending
// to the latitude phi (with constant scale and r = 1 for the equator)
// intersection(r) returns the direction from the pole to the extreme point
// where this parallel intersects the meridian lambda=pi/4.
function intersection(r) {
var r2 = r * r,
r4 = r2 * r2;
return atan2(sqrt(r2 - r4 / 4), r2 / 2) - pi / 6;
}
// once the extreme point is found, interpolate on the (circular) parallel
function forward(lambda, phi) {
var r = 1 - phi / halfPi,
angle = intersection(r) * (lambda / (pi / 4)),
x = r * sin(angle),
y = -r * cos(angle);
return [x, y];
}
forward.invert = function(x, y) {
var r = sqrt(x * x + y * y),
angle = atan2(x, -y),
lambda = (angle / intersection(r)) * (pi / 4);
return [lambda, halfPi * (1 - r)];
};
return forward;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more