<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/perspectiveRotate()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)perspectiveRotateFilter"
  },
  "title" : "perspectiveRotate()"
}
-->

# perspectiveRotate()

Rotates an image in a 3D space.

```
class func perspectiveRotate() -> any CIFilter & CIPerspectiveRotate
```

## Return Value

The adjusted image.

## Discussion

This method applies the perspective rotate filter to an image. The effect rotates the image in 3D space to simulate the observer changing viewing position.

The perspective rotate filter uses the following properties:

- `inputImage`: An image with the type [`CIImage`](/documentation/CoreImage/CIImage).
- `pitch`: A `float` representing the adjustment along the pitch axis in 3D space as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.
- `yaw`: A `float` representing the adjustment along the vertical axis as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.
- `roll`: A `float` representing the amount of horizontal axis in 3D space as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.
- `focalLength`: A `float` representing the simulated focal length as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.

The following code creates a filter that rotates the image:

```swift
func perspectiveRotate(inputImage: CIImage) -> CIImage {
    let perspectiveRotateFilter = CIFilter.perspectiveRotate()
    perspectiveRotateFilter.inputImage = inputImage
    perspectiveRotateFilter.pitch = 0
    perspectiveRotateFilter.yaw = 0.1
    perspectiveRotateFilter.roll = 0.3
    perspectiveRotateFilter.focalLength = 18
    return perspectiveRotateFilter.outputImage!
}
```

![Two photographs of a large building on the corner of an intersection. The building has small windows and is made of a brick structure. The photo on the left has no modifications to size or color. In the photo on the right, a perspective rotate filter is applied, resulting in the image becoming smaller and rotated.](images/com.apple.coreimage/media-3582225@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)