# ios – constrain a transferring circle in a bigger circle It is a lot simpler in the event you change the place the calculation is. As a substitute of making an attempt to calculate whether or not the circumference of the interior circle goes outdoors the outer circle you’ll be able to cut back this to have a look at the centres.

If in case you have an outer circle of radius `R` and an interior circle of radius `R'` then, as a result of they’re circles we are able to say that if the interior circle centre is larger than `(R - R')` away from the centre it will likely be outdoors the outer circle.

So, if the centre of the outer circle is at `(0,0)` then we simply must calculate the Pythagorean distance of the centre of the interior circle.

If the coordinates of the centre of the interior circle is `(x,y)` then we are able to do the calculation…

``````if x*x + y*y > (R - R') * (R - R') {
// interior circle is outdoors outer circle
}
``````

If the outer circle centre is just not at (0,0) then you definately simply have to make use of `dx` and `dy` within the calculation the place `dx = outer circle centre x - interior circle centre x` and identical for `dy`.