Uses geoVoronoi
to compute triangles from a set of points on the sphere.
Antenna radomes make use of quasi-random lattices to help limiting signal degradation.
The points on the are distributed by a Fibonnaci sphere algorithm. Once could probably use Poisson-disc sampling instead.
Inspiration: Trevor Paglen’s pictures of radomes at the NSA’s Menwith Hill Station in the UK.
forked from Fil's block: Fibonacci sphere quasi-random radome
xxxxxxxxxx
<meta charset="utf-8">
<style>
.polygons {
fill: #f4f4f4;
stroke: #000;
}
.polygons.found {
fill: #f00;
}
.sites {
fill: #000;
stroke: #fff;
}
</style>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://unpkg.com/d3-geo-voronoi"></script>
<script>
console.clear()
var radians = Math.PI / 180;
var spherical = function (cartesian) {
var r = Math.sqrt(cartesian[0] * cartesian[0] + cartesian[1] * cartesian[1]),
lat = Math.atan2(cartesian[2], r),
lng = Math.atan2(cartesian[1], cartesian[0]);
return [lng / radians, lat / radians];
}
var cartesian = function (spherical) {
var lambda = spherical[0] * radians,
phi = spherical[1] * radians,
cosphi = Math.cos(phi);
return [
cosphi * Math.cos(lambda),
cosphi * Math.sin(lambda),
Math.sin(phi)
];
}
function fibonacci_sphere(samples=1, randomize=true){
rnd = 1.
if (randomize) {
rnd = Math.random() * samples
}
var offset = 2./samples
var increment = Math.PI * (3. - Math.sqrt(5.));
return d3.range(samples)
.map(function(i) {
var y = ((i * offset) - 1) + (offset / 2),
r = Math.sqrt(1 - Math.pow(y,2)),
phi = ((i + rnd) % samples) * increment,
x = Math.cos(phi) * r,
z = Math.sin(phi) * r
return([x,y,z])
});
}
var sites = fibonacci_sphere(60, false).map(spherical);
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var color = function(t) {
return d3.hsl(280+40*t, 0.18, 0.4)
}
var voronoi = d3.geoVoronoi();
var init = 53;
var projection = d3.geoEquirectangular().rotate([0,0]);
var path = d3.geoPath()
.projection(projection);
var diagram = voronoi(sites);
var line = d3.line();
var polygon = svg.append("g")
.attr("class", "polygons")
.selectAll("path")
.data(voronoi.polygons(sites).features)
.enter().append("path")
.attr("d", path);
var surf = polygon.data().map(d3.geoArea);
var v = [d3.min(surf), d3.median(surf), d3.max(surf)];
console.log('v', v);
var color = d3.scaleLinear()
.domain(v)
.range(['blue', 'white', 'red']);
redraw();
if(false)
d3.interval(function(el){
projection.rotate([init+el/30, 0]);
redraw()
},60);
function redraw() {
polygon = polygon.call(redrawPolygon);
}
function redrawPolygon(polygon) {
polygon
.attr('fill', function(d) {
return color(d3.geoArea(d));
//console.log(t)
return ;
return d3.interpolate('white', color)(t);
})
.attr('stroke', '#666');
}
</script>
https://d3js.org/d3.v4.min.js
https://unpkg.com/d3-geo-voronoi