A dynamic model for action understanding and goal-directed imitation