http://stackoverflow.com/questions/18766430/how-can-i-do-d3-svg-arc-within-a-given-map-projectionの後に、ある方位角、天頂角、および所定の開き角で円弧を表示するように少し修正したバージョンがあります。これまでの私の努力は以下の通りです。D3円弧は必要に応じて表示されません
(Az、Ze)0,90と0,45で円弧を作成した場合、円弧は予想されるところです。しかし、Ze = 45度でAz = 45度ごとに円弧を欲しければ、円弧は周回するのではなく、投影から外れてしまう傾向があります。
ここで何が起こっているのでしょうか? Jsfiddleは:http://jsfiddle.net/3p9c4kzo/1/
var width = 600,
height = 600;
var flippedStereographic = function(lam, phi) {
var cosl = Math.cos(lam),
cosp = Math.cos(phi),
k = 1/(1 + cosl * cosp);
return [ k * cosp * Math.sin(lam), -k * Math.sin(phi) ];
};
var projection = d3.geo
.projection(flippedStereographic)
.rotate([0, -90])
.scale(180)
.translate([width/2, height/2])
.clipAngle(90)
.precision(.1);
var path = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("defs").append("path")
.datum({
type: "Sphere"
})
.attr("id", "sphere")
.attr("d", path);
svg.append("use")
.attr("class", "stroke")
.attr("xlink:href", "#sphere");
svg.append("use")
.attr("class", "fill")
.attr("xlink:href", "#sphere");
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
function geoArc(center, radius, startAngle, endAngle, steps) {
coordinates = []
for (var i = 0; i <= steps; i++) {
var curAngle = (startAngle + (endAngle - startAngle) * i/steps);
coordinates[i] = d3.geo.rotation(center)(d3.geo.rotation([0, 0,
curAngle])([radius, 0]))
}
return {
type: "LineString",
coordinates: coordinates
};
}
svg.append("path")
.datum(geoArc([0,90], 30, 0, 360, 40))
.classed("circle", true)
.attr("d", path);
svg.append("path")
.datum(geoArc([0,45], 30, 0, 360, 40))
.classed("circle", true)
.attr("d", path);
svg.append("path")
.datum(geoArc([45,45], 30, 0, 360, 40))
.classed("circle", true)
.attr("d", path);
svg.append("path")
.datum(geoArc([90,45], 30, 0, 360, 40))
.classed("circle", true)
.attr("d", path);
興味深いことに、Iは、方位角= 0がもはや指しているにもかかわらず、circle->楕円の正しい表現を見ません真北。私は、上に提示されたアルゴリズムは、正書法固有のものだと思います。 – smader