# Cross

> Calculates the cross product of two three-dimensional vectors.

## Definition

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

## Cross(Vector3, Vector3)

Calculates the cross product of two three-dimensional vectors.

```csharp
public static Vector3 Cross(Vector3 lhs, Vector3 rhs)
```

### Parameters

**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The first input vector.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The second input vector.

### Returns

| Type                                                              | Description                                                                              |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.7/script-reference/unityengine/vector3.md) | The cross product of the `lhs` and `rhs` vectors. This vector is usually not normalized. |

### Remarks

The cross product of two three-dimensional vectors results in a third vector which is perpendicular to the two input vectors. The result's magnitude is equal to the magnitudes of the two inputs multiplied together and then multiplied by the sine of the angle between the inputs. You can determine the direction of the result vector from the two input vectors using the "left hand rule".

![LeftHandRuleDiagram (Cross)](/api/media?file=/engine/6000.7/media/images/LeftHandRuleDiagram.png)

*The left hand rule applied to Cross(a, b).*

### Examples

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

public class ExampleClass : MonoBehaviour
{
    // Get the normal to a triangle from the three corner points a, b, and o, where o is the common origin point used to calculate two side vectors of the triangle.
    Vector3 GetNormal(Vector3 a, Vector3 b, Vector3 o)
    {
        // Calculate vectors corresponding to two of the sides of the triangle.
        Vector3 side1 = a - o;
        Vector3 side2 = b - o;

        // Cross the vectors to get a perpendicular vector, then normalize it. This is the Result vector in the drawing above.
        return Vector3.Cross(side1, side2).normalized;
    }
}
```

## Cross(Vector3, Vector3)

Calculates the cross product of two three-dimensional vectors.

```csharp
public static Vector3 Cross(in Vector3 lhs, in Vector3 rhs)
```

### Parameters

**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The first input vector.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The second input vector.

### Returns

| Type                                                              | Description                                                                              |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.7/script-reference/unityengine/vector3.md) | The cross product of the `lhs` and `rhs` vectors. This vector is usually not normalized. |

### Remarks

The cross product of two three-dimensional vectors results in a third vector which is perpendicular to the two input vectors. The result's magnitude is equal to the magnitudes of the two inputs multiplied together and then multiplied by the sine of the angle between the inputs. You can determine the direction of the result vector from the two input vectors using the "left hand rule".

![LeftHandRuleDiagram (Cross)](/api/media?file=/engine/6000.7/media/images/LeftHandRuleDiagram.png)

*The left hand rule applied to Cross(a, b).*

### Examples

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

public class ExampleClass : MonoBehaviour
{
    // Get the normal to a triangle from the three corner points a, b, and o, where o is the common origin point used to calculate two side vectors of the triangle.
    Vector3 GetNormal(Vector3 a, Vector3 b, Vector3 o)
    {
        // Calculate vectors corresponding to two of the sides of the triangle.
        Vector3 side1 = a - o;
        Vector3 side2 = b - o;

        // Cross the vectors to get a perpendicular vector, then normalize it. This is the Result vector in the drawing above.
        return Vector3.Cross(side1, side2).normalized;
    }
}
```
