# projectsafe

> Compute vector projection of a onto b. If result is not finite, then return the default value instead.

## Definition

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

## projectsafe(float2, float2, float2)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static float2 projectsafe(float2 a, float2 ontoB, float2 defaultValue = default)
```

### Parameters

**** (\[float2]\(/engine/6000.7/script-reference/unity/mathematics/float2)): Vector to project.**** (\[float2]\(/engine/6000.7/script-reference/unity/mathematics/float2)): Non-zero vector to project onto.**** (\[float2]\(/engine/6000.7/script-reference/unity/mathematics/float2)): Default value to return if projection is not finite.

### Returns

| Type                                                                  | Description                                         |
| --------------------------------------------------------------------- | --------------------------------------------------- |
| [float2](/engine/6000.7/script-reference/unity/mathematics/float2.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.

## projectsafe(float3, float3, float3)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static float3 projectsafe(float3 a, float3 ontoB, float3 defaultValue = default)
```

### Parameters

**** (\[float3]\(/engine/6000.7/script-reference/unity/mathematics/float3)): Vector to project.**** (\[float3]\(/engine/6000.7/script-reference/unity/mathematics/float3)): Non-zero vector to project onto.**** (\[float3]\(/engine/6000.7/script-reference/unity/mathematics/float3)): Default value to return if projection is not finite.

### Returns

| Type                                                                  | Description                                         |
| --------------------------------------------------------------------- | --------------------------------------------------- |
| [float3](/engine/6000.7/script-reference/unity/mathematics/float3.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.

## projectsafe(float4, float4, float4)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static float4 projectsafe(float4 a, float4 ontoB, float4 defaultValue = default)
```

### Parameters

**** (\[float4]\(/engine/6000.7/script-reference/unity/mathematics/float4)): Vector to project.**** (\[float4]\(/engine/6000.7/script-reference/unity/mathematics/float4)): Non-zero vector to project onto.**** (\[float4]\(/engine/6000.7/script-reference/unity/mathematics/float4)): Default value to return if projection is not finite.

### Returns

| Type                                                                  | Description                                         |
| --------------------------------------------------------------------- | --------------------------------------------------- |
| [float4](/engine/6000.7/script-reference/unity/mathematics/float4.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.

## projectsafe(double2, double2, double2)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static double2 projectsafe(double2 a, double2 ontoB, double2 defaultValue = default)
```

### Parameters

**** (\[double2]\(/engine/6000.7/script-reference/unity/mathematics/double2)): Vector to project.**** (\[double2]\(/engine/6000.7/script-reference/unity/mathematics/double2)): Non-zero vector to project onto.**** (\[double2]\(/engine/6000.7/script-reference/unity/mathematics/double2)): Default value to return if projection is not finite.

### Returns

| Type                                                                    | Description                                         |
| ----------------------------------------------------------------------- | --------------------------------------------------- |
| [double2](/engine/6000.7/script-reference/unity/mathematics/double2.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.

## projectsafe(double3, double3, double3)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static double3 projectsafe(double3 a, double3 ontoB, double3 defaultValue = default)
```

### Parameters

**** (\[double3]\(/engine/6000.7/script-reference/unity/mathematics/double3)): Vector to project.**** (\[double3]\(/engine/6000.7/script-reference/unity/mathematics/double3)): Non-zero vector to project onto.**** (\[double3]\(/engine/6000.7/script-reference/unity/mathematics/double3)): Default value to return if projection is not finite.

### Returns

| Type                                                                    | Description                                         |
| ----------------------------------------------------------------------- | --------------------------------------------------- |
| [double3](/engine/6000.7/script-reference/unity/mathematics/double3.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.

## projectsafe(double4, double4, double4)

Compute vector projection of a onto b. If result is not finite, then return the default value instead.

```csharp
public static double4 projectsafe(double4 a, double4 ontoB, double4 defaultValue = default)
```

### Parameters

**** (\[double4]\(/engine/6000.7/script-reference/unity/mathematics/double4)): Vector to project.**** (\[double4]\(/engine/6000.7/script-reference/unity/mathematics/double4)): Non-zero vector to project onto.**** (\[double4]\(/engine/6000.7/script-reference/unity/mathematics/double4)): Default value to return if projection is not finite.

### Returns

| Type                                                                    | Description                                         |
| ----------------------------------------------------------------------- | --------------------------------------------------- |
| [double4](/engine/6000.7/script-reference/unity/mathematics/double4.md) | Vector projection of a onto b or the default value. |

### Remarks

This function performs extra checks to see if the result of projecting a onto b is finite. If you know that your inputs will generate a finite result or you don't care if the result is finite, then you can call [\_project](/engine/6000.7/script-reference/unity/mathematics/math/project.md) instead which is faster than this function.
