Analytic Geometry Algorithms in javascript