> ## Documentation Index
> Fetch the complete documentation index at: https://lua.starline.one/llms.txt
> Use this file to discover all available pages before exploring further.

# Vector

> Create and manipulate Vector and QAngle values.

3D vector with math. `Vector(x, y, z)`.

```lua theme={"dark"}
local v = Vector(1, 2, 3)
v.x, v.y, v.z         -- 1, 2, 3 (writable)

local u = v + Vector(0, 0, 5)
local w = v * 2
local d = (v - u):Length()
```

## Fields

```lua theme={"dark"}
v.x, v.y, v.z
v.x = 100
```

## Arithmetic

|                  |                  |
| ---------------- | ---------------- |
| `v + u`          | component-wise   |
| `v - u`          | component-wise   |
| `v * s`, `s * v` | scale by number  |
| `v / s`          | divide by number |
| `-v`             | negation         |
| `v == u`         | exact equality   |

## Methods

|                 |                                                                  |
| --------------- | ---------------------------------------------------------------- |
| `v:Length()`    | euclidean length                                                 |
| `v:LengthSqr()` | squared length                                                   |
| `v:Distance(u)` | `(v - u):Length()`                                               |
| `v:Dot(u)`      | dot product                                                      |
| `v:Cross(u)`    | cross product, new `Vector`                                      |
| `v:Normalize()` | unit vector, new `Vector`; zero-length returns `Vector(0, 0, 0)` |

## QAngle

Euler angles: pitch, yaw, roll. `QAngle(pitch, yaw, roll)`.

```lua theme={"dark"}
local a = QAngle(0, 90, 0)
a.pitch, a.yaw, a.roll   -- 0, 90, 0 (writable)
```

No arithmetic (angles don't add cleanly outside specific contexts). Extract the fields if you need to do math on them.

## Passing to entity fields

Anywhere `entity.*` writes a `Vector` or `QAngle` schema field, both the typed object and a plain table work:

```lua theme={"dark"}
pawn.m_vecOrigin = Vector(0, 0, 0)
pawn.m_vecOrigin = { x = 0, y = 0, z = 0 }

pawn.m_angEyeAngles = QAngle(0, 90, 0)
pawn.m_angEyeAngles = { pitch = 0, yaw = 90, roll = 0 }
```

Reads always return the typed object.
