I'm using paper.js and need to add a point to a curved path without affecting the path's shape. Inkscape's "Edit paths by nodes" tool has this feature by default -- double-clicking on a path adds a node, adjusting the handles of the new node and adjacent nodes to preserve the path shape. What appears to be the code says "Handle lengths are equal to 1/3 of the distance from the adjacent node." I haven't managed to find the code which updates the handles of the adjacent nodes, but observing the behavior in Inkscape they appear to shrink to an amount proportional to the (along-path) distance to the new node.
Coding this up, it works well on a circle but isn't quite right for a less regular shape.
Any suggestions for making it work as reliably as Inkscape?