Computational geometry algorithm(s) in JavaScript