---
title: "projectionMatrix(viewRotationAngle:viewportSize:zNear:zFar:)"
framework: arkit
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+]
path: "arkit/arcamera/projectionmatrix(viewrotationangle:viewportsize:znear:zfar:)"
---

# projectionMatrix(viewRotationAngle:viewportSize:zNear:zFar:)

Creates a projection matrix for the camera given rendering parameters.

## Declaration

```swift
func projectionMatrix(viewRotationAngle: CGFloat, viewportSize: CGSize, zNear: CGFloat, zFar: CGFloat) -> simd_float4x4
```

## Parameters

- `viewRotationAngle`: View rotation angle in degrees.
- `viewportSize`: Viewport size.
- `zNear`: Near depth limit.
- `zFar`: Far depth limit.

## Return Value

Return Value The projection matrix for the given parameters.

## Discussion

Discussion The projection matrix returned provides an aspect fill for the provided viewport size and view angle. If zFar is set to 0, an infinite projection matrix will be returned. The view angle, in degrees, is the clockwise rotation needed to keep the camera image level with the horizon (0 LandscapeRight, 90 Portrait, 180 LandscapeLeft, 270 PortraitUpsideDown). Obtain it from ARSession.viewRotationAngle.
