Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Created August 29, 2013 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinmetcalf/6373459 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/6373459 to your computer and use it in GitHub Desktop.
// For closed lines, rotate to find a suitable shared starting point.
for (; k < n; ++k) {
var t = coincidences.peek(points[k]);
if (open) break;
if (p && !linesEqual(p, t)) {
var tInP = t.every(function(line) { return p.indexOf(line) >= 0; }),
pInT = p.every(function(line) { return t.indexOf(line) >= 0; });
if (tInP && !pInT) --k;
break;
}
p = t;
}
// If no shared starting point is found for closed lines, rotate to minimum.
if (k === n && p.length > 1) {
var point0 = points[0];
for (k = 0, i = 1; i < n; ++i) {
var point = points[i];
if (pointCompare(point0, point) > 0) point0 = point, k = i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment