copied util geom functions from jsplumb
documentation