         debugPrint("enclosingRect after = \(enclosingRect)")
         
         // 4. Транслируем центр полученного прямоугольника в исходную систему координат
-        let targetCenter = enclosingRect.center
+        let translateTransform = CGAffineTransformMakeTranslation(sourceCenter.x, sourceCenter.y)
+        let rotationTransform = CGAffineTransformMakeRotation(-angle)
+        let reverseTransform = CGAffineTransformConcat(
+            CGAffineTransformConcat(CGAffineTransformInvert(translateTransform), rotationTransform),
+            translateTransform
+        )
+        
+        let targetCenter = CGPointApplyAffineTransform(enclosingRect.center, reverseTransform)
+        debugPrint("targetCenter = \(targetCenter)")
         
         // 5. Рассчитываем contentOffset, при котором центром bounds окажется targetCenter
         targetContentOffset.memory = CGPoint(

            minScale = maxScale
        }
        
        maximumZoomScale = maxScale
        minimumZoomScale = minScale
        print("min scale = \(minScale), max scale = \(maxScale)")
    }
    
    // MARK: - Rotation support

    }
    
    private var imageRotation = CGFloat(0)
    private var imageScale = CGFloat(1)
    
    func setImageRotation(angle: CGFloat) {
        
        let radians = angle * CGFloat(M_PI) / 180
        let scale = scaleToFillBoundsWithImageRotatedBy(Double(radians))
        
        imageView.imageTransform = CGAffineTransformMakeRotation(radians)
        
        imageRotation = radians
        
        minimumZoomScale = scale
        zoomScale = scale
        debugPrint("scale =\(scale), zoomScale = \(zoomScale)")
    }
    
    // MARK: - UIScrollViewDelegate
