question: public void fixedAspectResizeInner ( RectF newInner ) { Matrix m = getRotMatrix ( ) ; Matrix m0 = getInverseRotMatrix ( ) ; float aspectW = inner . width ( ) ; float aspectH = inner . height ( ) ; float aspRatio = aspectW / aspectH ; float [ ] corners = CropMath . getCornersFromRect ( outer ) ; m . mapPoints ( corners ) ; float [ ] oldInnerCorners = CropMath . getCornersFromRect ( inner ) ; float [ ] newInnerCorners = CropMath . getCornersFromRect ( newInner ) ; int fixed = - 1 ; if ( inner . top == newInner . top ) { if ( inner . left == newInner . left ) fixed = 0 ; else if ( inner . right == newInner . right ) fixed = 2 ; } else if ( inner . bottom == newInner . bottom ) { if ( inner . right == newInner . right ) fixed = 4 ; else if ( inner . left == newInner . left ) fixed = 6 ; } if ( fixed == - 1 ) return ; float widthSoFar = newInner . width ( ) ; int moved = - 1 ; for ( int i = 0 ; i < newInnerCorners . length ; i += 2 ) { float [ ] c = { newInnerCorners [ i ] , newInnerCorners [ i + 1 ] } ; float [ ] c0 = Arrays . copyOf ( c , 2 ) ; m0 . mapPoints ( c0 ) ; if ( ! CropMath . inclusiveContains ( outer , c0 [ 0 ] , c0 [ 1 ] ) ) { moved = i ; if ( moved == fixed ) continue ; float [ ] l2 = CropMath . closestSide ( c , corners ) ; float [ ] l1 = { newInnerCorners [ i ] , newInnerCorners [ i + 1 ] , oldInnerCorners [ i ] , oldInnerCorners [ i + 1 ] } ; float [ ] p = GeometryMathUtils . lineIntersect ( l1 , l2 ) ; if ( p == null ) { p = new float [ 2 ] ; p [ 0 ] = oldInnerCorners [ i ] ; p [ 1 ] = oldInnerCorners [ i + 1 ] ; } float fixed_x = oldInnerCorners [ fixed ] ; float fixed_y = oldInnerCorners [ fixed + 1 ] ; float newWidth = Math . abs ( fixed_x - p [ 0 ] ) ; float newHeight = Math . abs ( fixed_y - p [ 1 ] ) ; newWidth = Math . max ( newWidth , aspRatio * newHeight ) ; if ( newWidth < widthSoFar ) widthSoFar = newWidth ; } } float heightSoFar = widthSoFar / aspRatio ; RectF ret = new RectF ( inner ) ; if ( fixed == 0 ) { ret . right = ret . left + widthSoFar ; ret . bottom = ret . top + heightSoFar ; } else if ( fixed == 2 ) { ret . left = ret . right - widthSoFar ; ret . bottom = ret . top + heightSoFar ; } else if ( fixed == 4 ) { ret . left = ret . right - widthSoFar ; ret . top = ret . bottom - heightSoFar ; } else if ( fixed == 6 ) { ret . right = ret . left + widthSoFar ; ret . top = ret . bottom - heightSoFar ; } float [ ] retCorners = CropMath . getCornersFromRect ( ret ) ; m0 . mapPoints ( retCorners ) ; innerRotated = retCorners ; reconstrain ( ) ; }
target:  Attempts to resize the inner rectangle.  If this would cause it to leave the bounding rect, clips the inner rectangle to fit while maintaining aspect ratio.