> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/api-reference/math-and-transform-types/vector.md).

# Vector

### Creating a Vector

Create an empty Vector:

```python
vector = sp.Vector()
```

Create a Vector from three components:

```python
vector = sp.Vector(
    1.0,
    2.0,
    3.0
)
```

Create a Vector from a list:

```python
vector = sp.Vector(
    [1.0, 2.0, 3.0]
)
```

A Vector can also be copied from another `sp.Vector`:

```python
copy = sp.Vector(vector)
```

### Components

Vector components are available through:

```python
vector.x
vector.y
vector.z
```

For example:

```python
vector = sp.Vector(
    1.0,
    2.0,
    3.0
)

print(vector.x)
print(vector.y)
print(vector.z)
```

The component properties can also be changed:

```python
vector.x = 10.0
vector.y = 20.0
vector.z = 30.0
```

### `list()`

Converts the Vector to a Python list.

```python
vector = sp.Vector(
    1.0,
    2.0,
    3.0
)

value = vector.list()
```

Returns:

```
[1.0, 2.0, 3.0]
```

### `length()`

Returns the Vector length.

```python
length = vector.length()
```

Returns:

```
float
```

### `lengthSquared()`

Returns the squared Vector length.

```python
lengthSquared = vector.lengthSquared()
```

Returns:

```
float
```

For:

```python
sp.Vector(1.0, 2.0, 3.0)
```

the result is:

```
14.0
```

### `normalised()`

Returns a normalized copy of the Vector.

```python
normalised = vector.normalised()
```

Returns:

```
sp.Vector
```

### `dot()`

Calculates the dot product with another Vector.

```python
a = sp.Vector(1.0, 2.0, 3.0)
b = sp.Vector(4.0, 5.0, 6.0)

result = a.dot(b)
```

Returns:

```
float
```

### `cross()`

Calculates the cross product with another Vector.

```python
a = sp.Vector(1.0, 2.0, 3.0)
b = sp.Vector(4.0, 5.0, 6.0)

result = a.cross(b)
```

Returns:

```
sp.Vector
```

For the values above:

```python
result.list()
```

returns:

```
[-3.0, 6.0, -3.0]
```

### Axis Vectors

Standard axis Vectors are available through:

```python
sp.Vector.xAxis()
sp.Vector.yAxis()
sp.Vector.zAxis()
```

They represent:

```
X → [1.0, 0.0, 0.0]
Y → [0.0, 1.0, 0.0]
Z → [0.0, 0.0, 1.0]
```

### Quick Reference

| API                  | Returns       |
| -------------------- | ------------- |
| `sp.Vector()`        | `sp.Vector`   |
| `sp.Vector(x, y, z)` | `sp.Vector`   |
| `sp.Vector(list)`    | `sp.Vector`   |
| `.x`, `.y`, `.z`     | `float`       |
| `list()`             | `list[float]` |
| `length()`           | `float`       |
| `lengthSquared()`    | `float`       |
| `normalised()`       | `sp.Vector`   |
| `dot(vector)`        | `float`       |
| `cross(vector)`      | `sp.Vector`   |
| `sp.Vector.xAxis()`  | `sp.Vector`   |
| `sp.Vector.yAxis()`  | `sp.Vector`   |
| `sp.Vector.zAxis()`  | `sp.Vector`   |

{% hint style="info" %}
Vector Parameters in Grid Studio are exposed through `.value` as Python lists.

See **Core API → Parameters** for Parameter value handling.
{% endhint %}
