How about adding a few comments in this hunk and the next one saying what is being done: removing virtual joints from the multi_dof / joint trajectories.

This is a style thing, but using the difference vector twice was a bit confusing when I did the first pass on the code. IMO scoping the two blocks for multi-dof and joint trajectories inside separate {} blocks and having two `difference` instances that live within that scope would be clearer. No need to clear() in between.