# distancesq

> Returns the squared distance between two float values.

## Definition

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

## distancesq(float, float)

Returns the squared distance between two float values.

```csharp
public static float distancesq(float x, float y)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): First value to use in distance computation.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Second value to use in distance computation.

### Returns

| Type                                                          | Description                           |
| ------------------------------------------------------------- | ------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The squared distance between x and y. |

## distancesq(float2, float2)

Returns the squared distance between two float2 vectors.

```csharp
public static float distancesq(float2 x, float2 y)
```

### Parameters

**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): First vector to use in distance computation.**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): Second vector to use in distance computation.

### Returns

| Type                                                          | Description                           |
| ------------------------------------------------------------- | ------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The squared distance between x and y. |

## distancesq(float3, float3)

Returns the squared distance between two float3 vectors.

```csharp
public static float distancesq(float3 x, float3 y)
```

### Parameters

**** (\[float3]\(/engine/6000.6/script-reference/unity/mathematics/float3)): First vector to use in distance computation.**** (\[float3]\(/engine/6000.6/script-reference/unity/mathematics/float3)): Second vector to use in distance computation.

### Returns

| Type                                                          | Description                           |
| ------------------------------------------------------------- | ------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The squared distance between x and y. |

## distancesq(float4, float4)

Returns the squared distance between two float4 vectors.

```csharp
public static float distancesq(float4 x, float4 y)
```

### Parameters

**** (\[float4]\(/engine/6000.6/script-reference/unity/mathematics/float4)): First vector to use in distance computation.**** (\[float4]\(/engine/6000.6/script-reference/unity/mathematics/float4)): Second vector to use in distance computation.

### Returns

| Type                                                          | Description                           |
| ------------------------------------------------------------- | ------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The squared distance between x and y. |

## distancesq(double, double)

Returns the squared distance between two double values.

```csharp
public static double distancesq(double x, double y)
```

### Parameters

**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): First value to use in distance computation.**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): Second value to use in distance computation.

### Returns

| Type                                                           | Description                           |
| -------------------------------------------------------------- | ------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | The squared distance between x and y. |

## distancesq(double2, double2)

Returns the squared distance between two double2 vectors.

```csharp
public static double distancesq(double2 x, double2 y)
```

### Parameters

**** (\[double2]\(/engine/6000.6/script-reference/unity/mathematics/double2)): First vector to use in distance computation.**** (\[double2]\(/engine/6000.6/script-reference/unity/mathematics/double2)): Second vector to use in distance computation.

### Returns

| Type                                                           | Description                           |
| -------------------------------------------------------------- | ------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | The squared distance between x and y. |

## distancesq(double3, double3)

Returns the squared distance between two double3 vectors.

```csharp
public static double distancesq(double3 x, double3 y)
```

### Parameters

**** (\[double3]\(/engine/6000.6/script-reference/unity/mathematics/double3)): First vector to use in distance computation.**** (\[double3]\(/engine/6000.6/script-reference/unity/mathematics/double3)): Second vector to use in distance computation.

### Returns

| Type                                                           | Description                           |
| -------------------------------------------------------------- | ------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | The squared distance between x and y. |

## distancesq(double4, double4)

Returns the squared distance between two double4 vectors.

```csharp
public static double distancesq(double4 x, double4 y)
```

### Parameters

**** (\[double4]\(/engine/6000.6/script-reference/unity/mathematics/double4)): First vector to use in distance computation.**** (\[double4]\(/engine/6000.6/script-reference/unity/mathematics/double4)): Second vector to use in distance computation.

### Returns

| Type                                                           | Description                           |
| -------------------------------------------------------------- | ------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | The squared distance between x and y. |
