Ball vs. Ball collisions: un-penetrating the ball

Hello :beam:

I have been reading tonypa’s vector tutorials(http://www.tonypa.pri.ee/vectors/tut09.html), and I came across a special case that I am not sure how to deal with.

Suppose I have a ball bouncing around inside of a larger ball (I will call it the wheel). Now I know how to tell when the ball moves out of the wheel, and how I am supposed to move it back in (at least according to tonypa: var penetration=wheel.r-(ball.r+v.len) )
What I understand this does is it moves the ball back inside of the other ball along the line defined between the center of the ball and the center of the wheel.
However, wouldn’t this be inaccurate? Shouldn’t the ball be moved back along the line of the ball’s original direction?

If so, how would I calculate the amount to move it back in?

Thanks in advance for your help.
Sorry if my post is confusing :wink: