# GSAIUtils

### Description

Math and vector utility functions.

### Functions

| Type    | Name                                                     |
| ------- | -------------------------------------------------------- |
| Vector3 | func clampedv3(vector: Vector3, limit: float) -> Vector3 |
| float   | func vector3\_to\_angle(vector: Vector3) -> float        |
| float   | func vector2\_to\_angle(vector: Vector2) -> float        |
| Vector2 | func angle\_to\_vector2(angle: float) -> Vector2         |
| Vector2 | func to\_vector2(vector: Vector3) -> Vector2             |
| Vector3 | func to\_vector3(vector: Vector2) -> Vector3             |

### Method Descriptions

#### clampedv3 (static)

```gdscript
func clampedv3(vector: Vector3, limit: float) -> Vector3
```

Returns the `vector` with its length capped to `limit`.

#### vector3\_to\_angle (static)

```gdscript
func vector3_to_angle(vector: Vector3) -> float
```

Returns an angle in radians between the positive X axis and the `vector`.

This assumes orientation for 3D agents that are upright and rotate around the Y axis.

#### vector2\_to\_angle (static)

```gdscript
func vector2_to_angle(vector: Vector2) -> float
```

Returns an angle in radians between the positive X axis and the `vector`.

#### angle\_to\_vector2 (static)

```gdscript
func angle_to_vector2(angle: float) -> Vector2
```

Returns a directional vector from the given orientation angle.

This assumes orientation for 2D agents or 3D agents that are upright and rotate around the Y axis.

#### to\_vector2 (static)

```gdscript
func to_vector2(vector: Vector3) -> Vector2
```

Returns a vector2 with `vector`'s x and y components.

#### to\_vector3 (static)

```gdscript
func to_vector3(vector: Vector2) -> Vector3
```

Returns a vector3 with `vector`'s x and y components and 0 in z.
