# faceforward

> Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \< 0, -n otherwise.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Mathematics](/engine/6000.5/script-reference/unity/mathematics.md)
* **Assembly:** UnityEngine.MathematicsModule

## faceforward(float2, float2, float2)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static float2 faceforward(float2 n, float2 i, float2 ng)
```

### Parameters

**** (\[float2]\(/engine/6000.5/script-reference/unity/mathematics/float2)): Vector to conditionally flip.**** (\[float2]\(/engine/6000.5/script-reference/unity/mathematics/float2)): First vector in direction comparison.**** (\[float2]\(/engine/6000.5/script-reference/unity/mathematics/float2)): Second vector in direction comparison.

### Returns

| Type                                                                  | Description                                                               |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [float2](/engine/6000.5/script-reference/unity/mathematics/float2.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |

## faceforward(float3, float3, float3)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static float3 faceforward(float3 n, float3 i, float3 ng)
```

### Parameters

**** (\[float3]\(/engine/6000.5/script-reference/unity/mathematics/float3)): Vector to conditionally flip.**** (\[float3]\(/engine/6000.5/script-reference/unity/mathematics/float3)): First vector in direction comparison.**** (\[float3]\(/engine/6000.5/script-reference/unity/mathematics/float3)): Second vector in direction comparison.

### Returns

| Type                                                                  | Description                                                               |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [float3](/engine/6000.5/script-reference/unity/mathematics/float3.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |

## faceforward(float4, float4, float4)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static float4 faceforward(float4 n, float4 i, float4 ng)
```

### Parameters

**** (\[float4]\(/engine/6000.5/script-reference/unity/mathematics/float4)): Vector to conditionally flip.**** (\[float4]\(/engine/6000.5/script-reference/unity/mathematics/float4)): First vector in direction comparison.**** (\[float4]\(/engine/6000.5/script-reference/unity/mathematics/float4)): Second vector in direction comparison.

### Returns

| Type                                                                  | Description                                                               |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [float4](/engine/6000.5/script-reference/unity/mathematics/float4.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |

## faceforward(double2, double2, double2)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static double2 faceforward(double2 n, double2 i, double2 ng)
```

### Parameters

**** (\[double2]\(/engine/6000.5/script-reference/unity/mathematics/double2)): Vector to conditionally flip.**** (\[double2]\(/engine/6000.5/script-reference/unity/mathematics/double2)): First vector in direction comparison.**** (\[double2]\(/engine/6000.5/script-reference/unity/mathematics/double2)): Second vector in direction comparison.

### Returns

| Type                                                                    | Description                                                               |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [double2](/engine/6000.5/script-reference/unity/mathematics/double2.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |

## faceforward(double3, double3, double3)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static double3 faceforward(double3 n, double3 i, double3 ng)
```

### Parameters

**** (\[double3]\(/engine/6000.5/script-reference/unity/mathematics/double3)): Vector to conditionally flip.**** (\[double3]\(/engine/6000.5/script-reference/unity/mathematics/double3)): First vector in direction comparison.**** (\[double3]\(/engine/6000.5/script-reference/unity/mathematics/double3)): Second vector in direction comparison.

### Returns

| Type                                                                    | Description                                                               |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [double3](/engine/6000.5/script-reference/unity/mathematics/double3.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |

## faceforward(double4, double4, double4)

Conditionally flips a vector n if two vectors i and ng are pointing in the same direction. Returns n if dot(i, ng) \\\< 0, -n otherwise.

```csharp
public static double4 faceforward(double4 n, double4 i, double4 ng)
```

### Parameters

**** (\[double4]\(/engine/6000.5/script-reference/unity/mathematics/double4)): Vector to conditionally flip.**** (\[double4]\(/engine/6000.5/script-reference/unity/mathematics/double4)): First vector in direction comparison.**** (\[double4]\(/engine/6000.5/script-reference/unity/mathematics/double4)): Second vector in direction comparison.

### Returns

| Type                                                                    | Description                                                               |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [double4](/engine/6000.5/script-reference/unity/mathematics/double4.md) | -n if i and ng point in the same direction; otherwise return n unchanged. |
