catmul-rom algorithm copied from processingJS. it has nice looking code comments.