I have a layer with a CAKeyframeAnimation that is animating it along a path. The layer also has a changing transform property as the animation's rotationMode is set to kCAAnimationRotateAuto.
When I tap the layer (which I'm detecting with a tap gesture recognizer and hit-testing the presentationLayer of the animated layer like in this question, if there's a better way to do this let me know), I want to do the following:
- Grab the position and transform from the presentation layer
 - Remove the current animation.
 - Using the info grabbed in step 1, add a new animation to the layer that maintains the transform and start point and slows the layer's transit to a new endpoint ~40 pixels from where the previous animation had just ended.
 
The end result should be that, when tapped, an animating layer will slow to a halt along a straight line that lies tangent to the path at the point where the original keyframe animation was removed.
How would I go about doing this, math-wise? I already have the start point and transform, so it seems to me that I just need to figure out the endpoint, perhaps by using the startpoint, transform, and distance (say 40 for fun). Any ideas?