Containment detection

I want my mouseDragged method to continuously drag a circle, while the circle remains within the bounds of a larger circe. When the smaller circle hits the circumference of the containing circle (i.e., the mouse moves outside the containing circle), the smaller circle can only be dragged around the containing circle's circumference.

Drag and drop methods are implemented in an NSView subclass. Circle properties are stored in a custom object currChar. currChar's draw method draws both dragging circle and containing circle. Circles are drawn as NSBezierPath ovals within rects. Problem is, I don't have enough knowledge of math to implement the containment algorithm. Can anyone help?

Is the distance between the centers of the circles greater than the difference of their radii?

If not, the small circle is inside the big one. Otherwise, you'll need to move the small circle back inside. Here's a vaguely relevant snippet, but bear in mind that it doesn't do exactly the same thing as you want to: