# mbostock/d3

### Subversion checkout URL

You can clone with
or
.

Fix d3.geo.circle.origin.

```3D rotations are not commutative, so we must perform an inverse rotation
to move something from origin [0, 0] to [λ, φ].  Normally we are moving
origin [λ, φ] to [0, 0].```
jasondavies authored
2  d3.js
 @@ -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));
2  d3.min.js
1 addition, 1 deletion not shown
2  src/geo/circle.js
 @@ -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, {
5 test/geo/circle-test.js
 @@ -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); } } });