Created
August 29, 2013 01:51
-
-
Save calvinmetcalf/6373459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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