function reorderFinderPatterns(pattern1, pattern2, pattern3) {
                        // Find distances between pattern centers
                        var oneTwoDistance = distance(pattern1, pattern2);
                        var twoThreeDistance = distance(pattern2, pattern3);
                        var oneThreeDistance = distance(pattern1, pattern3);
                        var bottomLeft;
                        var topLeft;
                        var topRight;
                        // Assume one closest to other two is B; A and C will just be guesses at first
                        if (twoThreeDistance >= oneTwoDistance && twoThreeDistance >= oneThreeDistance) {
                            _a = [pattern2, pattern1, pattern3], bottomLeft = _a[0], topLeft = _a[1], topRight = _a[2];
                        } else if (oneThreeDistance >= twoThreeDistance && oneThreeDistance >= oneTwoDistance) {
                            _b = [pattern1, pattern2, pattern3], bottomLeft = _b[0], topLeft = _b[1], topRight = _b[2];
                        } else {
                            _c = [pattern1, pattern3, pattern2], bottomLeft = _c[0], topLeft = _c[1], topRight = _c[2];
                        }
                        // Use cross product to figure out whether bottomLeft (A) and topRight (C) are correct or flipped in relation to topLeft (B)
                        // This asks whether BC x BA has a positive z component, which is the arrangement we want. If it's negative, then
                        // we've got it flipped around and should swap topRight and bottomLeft.
                        if (((topRight.x - topLeft.x) * (bottomLeft.y - topLeft.y)) - ((topRight.y - topLeft.y) * (bottomLeft.x - topLeft.x)) < 0) {
                            _d = [topRight, bottomLeft], bottomLeft = _d[0], topRight = _d[1];
                        }
                        return {
                            bottomLeft: bottomLeft,
                            topLeft: topLeft,
                            topRight: topRight
                        };
                        var _a, _b, _c, _d;
                    }
// Takes three finder patterns and organizes them into topLeft, topRight, etc
Takes three finder patterns and organizes them into topLeft, topRight, etc
Takes three finder patterns and organizes them into topLeft topRight etc
function reorderFinderPatterns(pattern1, pattern2, pattern3) {
                        var oneTwoDistance = distance(pattern1, pattern2);
                        var twoThreeDistance = distance(pattern2, pattern3);
                        var oneThreeDistance = distance(pattern1, pattern3);
                        var bottomLeft;
                        var topLeft;
                        var topRight;
                        if (twoThreeDistance >= oneTwoDistance && twoThreeDistance >= oneThreeDistance) {
                            _a = [pattern2, pattern1, pattern3], bottomLeft = _a[0], topLeft = _a[1], topRight = _a[2];
                        } else if (oneThreeDistance >= twoThreeDistance && oneThreeDistance >= oneTwoDistance) {
                            _b = [pattern1, pattern2, pattern3], bottomLeft = _b[0], topLeft = _b[1], topRight = _b[2];
                        } else {
                            _c = [pattern1, pattern3, pattern2], bottomLeft = _c[0], topLeft = _c[1], topRight = _c[2];
                        }
                        if (((topRight.x - topLeft.x) * (bottomLeft.y - topLeft.y)) - ((topRight.y - topLeft.y) * (bottomLeft.x - topLeft.x)) < 0) {
                            _d = [topRight, bottomLeft], bottomLeft = _d[0], topRight = _d[1];
                        }
                        return {
                            bottomLeft: bottomLeft,
                            topLeft: topLeft,
                            topRight: topRight
                        };
                        var _a, _b, _c, _d;
                    }
function reorderFinderPatterns ( pattern1 , pattern2 , pattern3 ) { var oneTwoDistance = distance ( pattern1 , pattern2 ) ; var twoThreeDistance = distance ( pattern2 , pattern3 ) ; var oneThreeDistance = distance ( pattern1 , pattern3 ) ; var bottomLeft ; var topLeft ; var topRight ; if ( twoThreeDistance >= oneTwoDistance && twoThreeDistance >= oneThreeDistance ) { _a = [ pattern2 , pattern1 , pattern3 ] , bottomLeft = _a [ 0 ] , topLeft = _a [ 1 ] , topRight = _a [ 2 ] ; } else if ( oneThreeDistance >= twoThreeDistance && oneThreeDistance >= oneTwoDistance ) { _b = [ pattern1 , pattern2 , pattern3 ] , bottomLeft = _b [ 0 ] , topLeft = _b [ 1 ] , topRight = _b [ 2 ] ; } else { _c = [ pattern1 , pattern3 , pattern2 ] , bottomLeft = _c [ 0 ] , topLeft = _c [ 1 ] , topRight = _c [ 2 ] ; } if ( ( ( topRight . x - topLeft . x ) * ( bottomLeft . y - topLeft . y ) ) - ( ( topRight . y - topLeft . y ) * ( bottomLeft . x - topLeft . x ) ) < 0 ) { _d = [ topRight , bottomLeft ] , bottomLeft = _d [ 0 ] , topRight = _d [ 1 ] ; } return { bottomLeft : bottomLeft , topLeft : topLeft , topRight : topRight } ; var _a , _b , _c , _d ; }
Takes three finder patterns and organizes them into topLeft, topRight, etc
Takes three finder patterns and organizes them into topLeft topRight etc
// Find distances between pattern centers // Assume one closest to other two is B; A and C will just be guesses at first // Use cross product to figure out whether bottomLeft (A) and topRight (C) are correct or flipped in relation to topLeft (B) // This asks whether BC x BA has a positive z component, which is the arrangement we want. If it's negative, then // we've got it flipped around and should swap topRight and bottomLeft.