Frederik,
Yes, I noticed both of those issues but didn't mention them as my post was already pretty long.
I think even a single-contour, starting-point-insensitive morph would be extremely useful. It would cover the vast majority of cases outside of letters and even for letters would cover movement, scaling, and rotation, (and color if you add that in as I did).
Even weird morphs are often acceptable, and in many cases they aren't that weird especially when morphing a shape into another version of itself (at different scale, rotation, position, and/or color).
I would dearly love to have such a thing right now. I need to smoothly morph a stacked bar chart into a series of donut charts in specific locations. Your current morph would probably do that in a single bound.
So YES, please post or send me your code! Do you have it in the form of a custom node that I could just snap into place?
In fact, if you don't have time to work on it, I'd encourage you to release it as a built-in node. For v1 just include a note in documentation that it doesn't currently handle multiple contours as gracefully as it might. Later you could issue an update with the improved version; I don't think doing so would break the code of anyone using the more limited morph.
That said, I think both problems are solvable. It sounds like you already have a pretty good idea how to tackle starting position. My first cut at that would have been to define 8 possible compass points for a starting position (North, NorthEast, East, etc.) based on a comparison of the initial path position to the centroid, and then shift the target path until its start matched the same compass point as the source path. You could guess at rotation based on the first two positions in a path with different x values (second point east of start = clockwise).
That approach is not precise, but my hunch is that it most cases it would produce acceptable morphs. I think some mild rotation during a morph is acceptable even when it's not strictly necessary; this technique would probably avoid violent flips and twists. (You may already have an even better approach.)
One important point, though. I think it might be extremely useful to give users an option to control the matching of starting points. Many times they won't care and the default behavior will be good enough. But sometimes they will.
For example, when I morph from a stacked bar to a donut I want all the segments to move together and slowly bend into place. Ideally, if the target donut is west of the bar I want the bar to curve clockwise and if east counterclockwise. Any algorithm you come up with might cause some of the segments to behave differently than their peers or flop about unnecessarily.
One easy way to afford this control would be to simply expose an optional shift index. At 0 (the default) the target path is unshifted relative the normal morphing algorithm. If non-zero, you simply shift the points again after whatever shifting your algorithm already did. The user could experiment with this index until they got the precise affect they wanted. For bonus points you could also provide a second checkbox to reverse the path order of the target path; this would let users switch from clockwise to counterclockwise if need be.
Providing this user control might also relieve any anxiety you have about perfecting your algorithm. Your algorithm doesn't have to be perfect if users have the ability to adjust it when needed. In fact you could release your morph as is (with no attempt to automatically adjust starting position) and let users adjust it themselves (if they care). I would be happy with that.
To handle contours my first instinct is to break the morph into a series of separate simultaneous morphs. To morph from a triangle to the letter O, I would feed the triangle path into the outer contour and simultaneously feed the same triangle path into the inner contour. (This implies an extra step to classify contours as outer vs. inner.)
Morphing multiple-to-multiple contour shapes becomes complex if you to need to determine and respect hierarchies of contours (which in theory could be arbitrarily deep, though in practice more than two levels are probably rare). My instinct here is to not to let the perfect become the enemy of the good. It might be sufficient to map source outer contour to target outer contour and then morph any remaining inner contours to each other at random. For text strings there might be a bit of momentary weirdness inside a subset of letters but I suspect the overall movement would be relatively orderly.
Those are my initial thoughts. If I have any inspirations I will pass them along. In the meantime I look forward to trying your not-yet-perfect-but-alreadly-extremely-useful morphing code.
Thanks!
John