首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(反转)赤平投影上的D3圆弧未按要求显示

(反转)赤平投影上的D3圆弧未按要求显示
EN

Stack Overflow用户
提问于 2017-05-31 12:25:59
回答 1查看 133关注 0票数 1

http://stackoverflow.com/questions/18766430/how-can-i-do-d3-svg-arc-within-a-given-map-projection之后,我有了一个略微修改的版本,我想要在某个方位角、天顶角和给定的开放角度上显示一条圆弧。到目前为止,我的努力如下所示。

如果我在(Az,Ze) 0,90和0,45处创建一条圆弧,这些圆弧就是我期望的位置。但是,如果我想在Ze = 45度的每个Az = 45度处绘制一条圆弧,那么圆弧往往会偏离投影,而不是绕着它转。

知道这里发生了什么吗?Jsfiddle:http://jsfiddle.net/3p9c4kzo/1/

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2017-07-14 10:40:09

该代码似乎既适用于正交投影,也适用于立体投影。正交是扭曲的,不是共形的,而立体是共形的,不会扭曲(好吧,没有那么多)。

正交https://au.mathworks.com/help/map/ortho.html

极射https://au.mathworks.com/help/map/stereo.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44275636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档