private void makeIrisInBounds(float simulationRate){
  float irisOffsetX=mIrisPosition.x - mEyePosition.x;
  float irisOffsetY=mIrisPosition.y - mEyePosition.y;
  float maxDistance=mEyeRadius - mIrisRadius;
  float distance=(float)Math.sqrt(Math.pow(irisOffsetX,2) + Math.pow(irisOffsetY,2));
  if (distance <= maxDistance) {
    mConsecutiveBounces=0;
    return;
  }
  mConsecutiveBounces++;
  float ratio=maxDistance / distance;
  float x=mEyePosition.x + (ratio * irisOffsetX);
  float y=mEyePosition.y + (ratio * irisOffsetY);
  float dx=x - mIrisPosition.x;
  vx=applyBounce(vx,dx,simulationRate) / mConsecutiveBounces;
  float dy=y - mIrisPosition.y;
  vy=applyBounce(vy,dy,simulationRate) / mConsecutiveBounces;
  mIrisPosition=new PointF(x,y);
}

private void makeIrisInBounds ( float simulationRate ) { float irisOffsetX = mIrisPosition . x - mEyePosition . x ; float irisOffsetY = mIrisPosition . y - mEyePosition . y ; float maxDistance = mEyeRadius - mIrisRadius ; float distance = ( float ) Math . sqrt ( Math . pow ( irisOffsetX , 2 ) + Math . pow ( irisOffsetY , 2 ) ) ; if ( distance <= maxDistance ) { mConsecutiveBounces = 0 ; return ; } mConsecutiveBounces ++ ; float ratio = maxDistance / distance ; float x = mEyePosition . x + ( ratio * irisOffsetX ) ; float y = mEyePosition . y + ( ratio * irisOffsetY ) ; float dx = x - mIrisPosition . x ; vx = applyBounce ( vx , dx , simulationRate ) / mConsecutiveBounces ; float dy = y - mIrisPosition . y ; vy = applyBounce ( vy , dy , simulationRate ) / mConsecutiveBounces ; mIrisPosition = new PointF ( x , y ) ; }
correct the iris position to be in - bounds within the eye , if it is now out of bounds . being out of bounds could have been due to a sudden movement of the head and / or camera , or the result of just bouncing / rolling around . < p > in addition , modify the velocity to cause a bounce in the opposite direction .
