Friday, October 7, 2022
HomeiOS Developmentios - How one can constrain a transferring circle in a bigger...

ios – How one can constrain a transferring circle in a bigger circle


It is a lot simpler if you happen to change the place the calculation is. As an alternative of attempting to calculate whether or not the circumference of the inside circle goes exterior the outer circle you may cut back this to have a look at the centres.

You probably have an outer circle of radius R and an inside circle of radius R' then, as a result of they’re circles we will say that if the inside circle centre is larger than (R - R') away from the centre will probably be exterior the outer circle.

So, if the centre of the outer circle is at (0,0) then we simply have to calculate the Pythagorean distance of the centre of the inside circle.

If the coordinates of the centre of the inside circle is (x,y) then we will do the calculation…

if x*x + y*y > (R - R') * (R - R') {
  // inside circle is exterior outer circle
}

If the outer circle centre shouldn’t be at (0,0) you then simply have to make use of dx and dy within the calculation the place dx = outer circle centre x - inside circle centre x and identical for dy.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments