Geometry functions used internally by jsPlumb. Perhaps useful for other people.