aureooms/js-convex-hull-2d

View on GitHub
js/src/0-core/lib/origin.js

Summary

Maintainability
A
0 mins
Test Coverage

const origin = function ( { lex } , points ) {

    const bottomleft = argmin( lex , points , 0 , points.length ) ;
    const a = points[bottomleft] ;
    points[bottomleft] = points[0] ;
    points[0] = a ;

    //                -----
    //         -----
    //       ----  -- - -- - -- -
    //      -----  --- -- --
    //     ------
    //     a ---      ----
    //        --- - -- - -
    //          -- - -- -

    return a ;

} ;

exports.origin = origin ;