> For the complete documentation index, see [llms.txt](https://gdquest.gitbook.io/godot-3-steering-ai-framework-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gdquest.gitbook.io/godot-3-steering-ai-framework-reference/code-reference/gsaiutils.md).

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gdquest.gitbook.io/godot-3-steering-ai-framework-reference/code-reference/gsaiutils.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
