Skip to content

Commit d0ef84f

Browse files
committed
Optimize d3_geo_circleClipRotation.
1 parent 34180a7 commit d0ef84f

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

d3.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5784,12 +5784,10 @@
57845784
}
57855785
};
57865786
}
5787-
var d3_geo_circleClipRotation = function() {
5788-
var rotate = d3_geo_rotation(0, -π / 2, 0);
5789-
return function(point) {
5790-
return rotate(point[0], point[1]);
5791-
};
5792-
}();
5787+
function d3_geo_circleClipRotation(point) {
5788+
var λ = point[0], φ = point[1], cosφ = Math.cos(φ);
5789+
return [ Math.atan2(Math.sin(λ) * cosφ, Math.sin(φ)), Math.asin(Math.max(-1, Math.min(1, -Math.cos(λ) * cosφ))) ];
5790+
}
57935791
function d3_geo_circleClipPolygon(coordinates, context, clipLine, interpolate) {
57945792
var subject = [], clip = [], segments = [], buffer = d3_geo_circleBufferSegments(clipLine), visibleArea = 0, invisibleArea = 0, invisible = false;
57955793
coordinates.forEach(function(ring) {

0 commit comments

Comments
 (0)