8000 Polar polygon grids by etpinard · Pull Request #2739 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Polar polygon grids #2739

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

Merged
merged 20 commits into from
Jun 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use Lib.mod to cycle indices
  • Loading branch information
etpinard committed Jun 26, 2018
commit 1ca65080d138a42442197b9389c04ab9b0cdbeca
16 changes: 6 additions & 10 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,12 @@ proto.updateMainDrag = function(fullLayout, polarLayout) {
}

function findEnclosingVertexAngles(a) {
var cycleIndex = makeCycleIndexFn(vangles.length);
var i0 = findIndexOfMin(vangles, function(v) {
var adelta = angleDelta(v, a);
return adelta > 0 ? adelta : Infinity;
});
return [vangles[i0], vangles[cycleIndex(i0 + 1)]];
var i1 = Lib.mod(i0 + 1, vangles.length);
return [vangles[i0], vangles[i1]];
}

function findPolygonRadius(x, y, va0, va1) {
Expand Down Expand Up @@ -1391,13 +1391,6 @@ function findXYatLength(l, m, xp, yp) {
];
}

function makeCycleIndexFn(len) {
return function(index) {
return index < 0 ? len + index :
index < len ? index : index - len;
};
}

function makeRegularPolygon(r, vangles) {
var len = vangles.length;
var vertices = new Array(len + 1);
Expand All @@ -1423,7 +1416,10 @@ function makeClippedPolygon(r, sector, vangles) {
return findIntersectionXY(va0, va1, s, a2xy(va0));
}

var cycleIndex = makeCycleIndexFn(len);
function cycleIndex(ind) {
return Lib.mod(ind, len);
}

var s0 = deg2rad(sector[0]);
var s1 = deg2rad(sector[1]);

Expand Down
0