# Class Vector3Extensions

UnityEngine.Vector3 Based Extension Methods

##### Inheritance

**Namespace**: GDX

##### Syntax

`public static class Vector3Extensions`

### Methods

| Improve this Doc View Source#### Approximately(Vector3, Vector3)

Is one UnityEngine.Vector3 approximately similar to another UnityEngine.Vector3?

##### Declaration

`public static bool Approximately(this Vector3 targetVector3, Vector3 otherVector3)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | Point A |

UnityEngine.Vector3 | otherVector3 | Point B |

##### Returns

Type | Description |
---|---|

System.Boolean | Are the two UnityEngine.Vector3 approximately the same? |

##### Remarks

Includes optimized Unity.Mathematics approach.

#### DistanceSqr(Vector3, Vector3)

Calculate the squared distance between two UnityEngine.Vector3.

##### Declaration

`public static float DistanceSqr(this Vector3 targetVector3, Vector3 otherVector3)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | Point A |

UnityEngine.Vector3 | otherVector3 | Point B |

##### Returns

Type | Description |
---|---|

System.Single | The squared distance. |

##### Remarks

Based on https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance.

#### DistanceToRay(Vector3, Ray)

Calculate the distance from a UnityEngine.Vector3 to a UnityEngine.Ray.

##### Declaration

`public static float DistanceToRay(this Vector3 targetVector3, Ray targetRay)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | The position. |

UnityEngine.Ray | targetRay | The line. |

##### Returns

Type | Description |
---|---|

System.Single | The distance. |

#### HorizontalDistance(Vector3, Vector3)

Get the horizontal distance between two UnityEngine.Vector3 points.

##### Declaration

`public static float HorizontalDistance(this Vector3 targetVector3, Vector3 otherVector3)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | Point A |

UnityEngine.Vector3 | otherVector3 | Point B |

##### Returns

Type | Description |
---|---|

System.Single | The horizontal distance. |

##### Remarks

Ignores the Y-axis completely.

#### Midpoint(Vector3, Vector3)

Get the midpoint between two UnityEngine.Vector3s.

##### Declaration

`public static Vector3 Midpoint(this Vector3 targetVector3, Vector3 otherVector3)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | Point A |

UnityEngine.Vector3 | otherVector3 | Point B |

##### Returns

Type | Description |
---|---|

UnityEngine.Vector3 | The midpoint between |

#### NearestIndex(Vector3, Vector3[])

Find the index of the UnityEngine.Vector3 in `otherVector3`

that is nearest to the
`targetVector3`

.

##### Declaration

`public static int NearestIndex(this Vector3 targetVector3, Vector3[] otherVector3)`

##### Parameters

Type | Name | Description |
---|---|---|

UnityEngine.Vector3 | targetVector3 | The UnityEngine.Vector3 to use as the point of reference. |

UnityEngine.Vector3[] | otherVector3 | An array of UnityEngine.Vector3 positions to evaluate for which one is nearest. |

##### Returns

Type | Description |
---|---|

System.Int32 | The index of the nearest |