private void clampStartingPosition ( ) { final float cX = mBounds . exactCenterX ( ) ; final float cY = mBounds . exactCenterY ( ) ; final float dX = mStartingX - cX ; final float dY = mStartingY - cY ; final float r = mTargetRadius ; if ( dX * dX + dY * dY > r * r ) { // Point is outside the circle, clamp to the perimeter. final double angle = Math . atan2 ( dY , dX ) ; mClampedStartingX = cX + ( float ) ( Math . cos ( angle ) * r ) ; mClampedStartingY = cY + ( float ) ( Math . sin ( angle ) * r ) ; } else { mClampedStartingX = mStartingX ; mClampedStartingY = mStartingY ; } }
Clamps the starting position to fit within the ripple bounds .