Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix d3.geo.circle.origin. #983

Merged
merged 1 commit into from Jan 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion d3.js
Expand Up @@ -5671,7 +5671,7 @@
d3.geo.circle = function() {
var origin = [ 0, 0 ], angle, precision = 6, interpolate;
function circle() {
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0), ring = [];
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];
interpolate(null, null, 1, {
point: function(x, y) {
ring.push(x = rotate(x, y));
Expand Down
2 changes: 1 addition & 1 deletion d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/geo/circle.js
Expand Up @@ -6,7 +6,7 @@ d3.geo.circle = function() {

function circle() {
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin,
rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0),
rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert,
ring = [];

interpolate(null, null, 1, {
Expand Down
5 changes: 5 additions & 0 deletions test/geo/circle-test.js
Expand Up @@ -17,6 +17,11 @@ suite.addBatch({
var o = circle.origin([0, 90])();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates, [d3.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6);
},
"origin([45, 45])": function(circle) {
var o = circle.origin([45, 45]).angle(0)();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates[0][0], [45, 45], 1e-6);
}
}
});
Expand Down