Published
Edited
Jan 16, 2022
1 star
Insert cell
Insert cell
Insert cell
golden_ratio = (1.0 + Math.sqrt(5)) / 2
Insert cell
golden_angle = 2.0 * Math.PI * (1.0 - 1.0 / golden_ratio)
Insert cell
Insert cell
Insert cell
function* plot_phyllotaxis(count, radius) {
for (let i = 1; i <= count; ++i) {
const theta = i * golden_angle;
const r = Math.sqrt(i / count);
const x = Math.cos(theta) * r * radius;
const y = Math.sin(theta) * r * radius;
yield node2d(x, y, 4);
}
}
Insert cell
Insert cell
Insert cell
function cylindrical_phyllotaxis(count, radius, h) {
let positions = [];
for (let i = 1; i <= count; ++i) {
const theta = i * golden_angle;
const x = Math.cos(theta) * radius;
const y = Math.sin(theta) * radius;
const z = i * (h / count);
positions.push(...[x, z, y]);
}
return node3d(positions);
}
Insert cell
Insert cell
Insert cell
function hemispherical_phyllotaxis(count, radius) {
let positions = [];
for (let i = 1; i <= count; ++i) {
const phi = Math.acos(1.0 - i / count);
const theta = i * golden_angle;
const x = Math.sin(phi) * Math.cos(theta) * radius;
const y = Math.sin(phi) * Math.sin(theta) * radius;
const z = Math.cos(phi) * radius;
positions.push(...[x, z, y]);
}
return node3d(positions);
}
Insert cell
Insert cell
Insert cell
function spherical_phyllotaxis(count, radius) {
let positions = [];
for (let i = 1; i <= count; ++i) {
const phi = Math.acos(1.0 - 2.0 * i / count);
const theta = i * golden_angle;
const x = Math.sin(phi) * Math.cos(theta) * radius;
const y = Math.sin(phi) * Math.sin(theta) * radius;
const z = Math.cos(phi) * radius;
positions.push(...[x, z, y]);
}
return node3d(positions);
}
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