# CalculateFrustumPlanes

> Calculates frustum planes.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## CalculateFrustumPlanes(Camera)

Calculates frustum planes.

```csharp
public static Plane[] CalculateFrustumPlanes(Camera camera)
```

### Parameters

**** (\[Camera]\(/engine/6000.0/script-reference/unityengine/camera)): The camera with the view frustum that you want to calculate planes from.

### Returns

| Type                                                              | Description                                     |
| ----------------------------------------------------------------- | ----------------------------------------------- |
| [Plane\[\]](/engine/6000.0/script-reference/unityengine/plane.md) | The planes that form the camera's view frustum. |

### Remarks

This function takes the given camera's view frustum and returns six planes that form it. The normal of each plane points into the frustum.

Ordering: \[0] = Left, \[1] = Right, \[2] = Bottom, \[3] = Top, \[4] = Near, \[5] = Far

Additional Resources: [Plane](/engine/6000.0/script-reference/unityengine/plane.md), [GeometryUtility.TestPlanesAABB](/engine/6000.0/script-reference/unityengine/geometryutility/testplanesaabb.md).

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        // Calculate the planes from the main camera's view frustum
        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);

        // Create a "Plane" GameObject aligned to each of the calculated planes
        for (int i = 0; i < 6; ++i)
        {
            GameObject p = GameObject.CreatePrimitive(PrimitiveType.Plane);
            p.name = "Plane " + i.ToString();
            p.transform.position = -planes[i].normal * planes[i].distance;
            p.transform.rotation = Quaternion.FromToRotation(Vector3.up, planes[i].normal);
        }
    }
}
```

## CalculateFrustumPlanes(Matrix4x4)

Calculates frustum planes.

```csharp
public static Plane[] CalculateFrustumPlanes(Matrix4x4 worldToProjectionMatrix)
```

### Parameters

**** (\[Matrix4x4]\(/engine/6000.0/script-reference/unityengine/matrix4x4)): A matrix that transforms from world space to projection space, from which the planes will be calculated.

### Returns

| Type                                                              | Description                                                           |
| ----------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Plane\[\]](/engine/6000.0/script-reference/unityengine/plane.md) | The planes that enclose the projection space described by the matrix. |

### Remarks

This function returns six planes of a frustum defined by the given view & projection matrix.

Additional Resources: [Plane](/engine/6000.0/script-reference/unityengine/plane.md), [GeometryUtility.TestPlanesAABB](/engine/6000.0/script-reference/unityengine/geometryutility/testplanesaabb.md).

## CalculateFrustumPlanes(Camera, Plane\[])

Calculates frustum planes.

```csharp
public static void CalculateFrustumPlanes(Camera camera, Plane[] planes)
```

### Parameters

**** (\[Camera]\(/engine/6000.0/script-reference/unityengine/camera)): The camera with the view frustum that you want to calculate planes from.**** (\[Plane\[]]\(/engine/6000.0/script-reference/unityengine/plane)): An array of 6 Planes that will be overwritten with the calculated plane values.

### Remarks

This function takes the given camera's view frustum and returns six planes that form it. This is similar to the previous overload, except that instead of allocating a new array for the calculated planes, the function will use an array that you have provided. This array must always be exactly of length 6.

Ordering: \[0] = Left, \[1] = Right, \[2] = Down, \[3] = Up, \[4] = Near, \[5] = Far

Additional Resources: [Plane](/engine/6000.0/script-reference/unityengine/plane.md), [GeometryUtility.TestPlanesAABB](/engine/6000.0/script-reference/unityengine/geometryutility/testplanesaabb.md).

## CalculateFrustumPlanes(Matrix4x4, Plane\[])

Calculates frustum planes.

```csharp
public static void CalculateFrustumPlanes(Matrix4x4 worldToProjectionMatrix, Plane[] planes)
```

### Parameters

**** (\[Matrix4x4]\(/engine/6000.0/script-reference/unityengine/matrix4x4)): A matrix that transforms from world space to projection space, from which the planes will be calculated.**** (\[Plane\[]]\(/engine/6000.0/script-reference/unityengine/plane)): An array of 6 Planes that will be overwritten with the calculated plane values.

### Remarks

This function returns six planes of a frustum defined by the given view & projection matrix. This is similar to the previous overload, except that instead of allocating a new array for the calculated planes, the function will use an array that you have provided. This array must always be exactly of length 6.

Additional Resources: [Plane](/engine/6000.0/script-reference/unityengine/plane.md), [GeometryUtility.TestPlanesAABB](/engine/6000.0/script-reference/unityengine/geometryutility/testplanesaabb.md).
