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

# Radar coordinates

> Convert world x / y to pixels on a map's radar image.

Positions in the API (`x`, `y`, `z` in `/states`, kills, damage, grenades, bomb events) and in the parquet files
(`X`, `Y`, `Z`) are Hammer world units. To draw them on a map's 1024 x 1024 px radar image, use the map's overview
transform: `(pos_x, pos_y)` is the world position of the image's top-left corner and `scale` is world units per pixel.

```
px = (x - pos_x) / scale
py = (pos_y - y) / scale      # image y grows downwards, world y grows upwards
```

## Overview transforms

From the game's own `resource/overviews/de_<map>.txt` files.

| Map | `pos_x` | `pos_y` | `scale` | `lower` |
| - | - | - | - | - |
| ancient | -2953 | 2164 | 5 | |
| anubis | -2796 | 3328 | 5.22 | |
| cache | -2000 | 3250 | 5.5 | |
| dust2 | -2476 | 3239 | 4.4 | |
| inferno | -2087 | 3870 | 4.9 | |
| mirage | -3230 | 1713 | 5 | |
| nuke | -3453 | 2887 | 7 | -495 |
| overpass | -4831 | 1781 | 5.2 | |
| train | -2308 | 2078 | 4.082077 | -50 |
| vertigo | -3168 | 1762 | 4 | 11700 |

`GET /v1/maps` lists the maps that are in the data.

## Multi-level maps

Nuke, Train and Vertigo have a second radar image for the lower level. A position with `z` below `lower` belongs on
the lower image; the same `pos_x`, `pos_y` and `scale` apply.

## Code

```python theme={null}
OVERVIEWS = {
    "ancient":  dict(pos_x=-2953, pos_y=2164, scale=5),
    "anubis":   dict(pos_x=-2796, pos_y=3328, scale=5.22),
    "cache":    dict(pos_x=-2000, pos_y=3250, scale=5.5),
    "dust2":    dict(pos_x=-2476, pos_y=3239, scale=4.4),
    "inferno":  dict(pos_x=-2087, pos_y=3870, scale=4.9),
    "mirage":   dict(pos_x=-3230, pos_y=1713, scale=5),
    "nuke":     dict(pos_x=-3453, pos_y=2887, scale=7, lower=-495),
    "overpass": dict(pos_x=-4831, pos_y=1781, scale=5.2),
    "train":    dict(pos_x=-2308, pos_y=2078, scale=4.082077, lower=-50),
    "vertigo":  dict(pos_x=-3168, pos_y=1762, scale=4, lower=11700),
}

def to_radar(map_name, x, y, z=None):
    """World position -> (px, py, level) on the 1024 x 1024 radar. level is 'lower' or 'upper'."""
    o = OVERVIEWS[map_name.removeprefix("de_")]
    px = (x - o["pos_x"]) / o["scale"]
    py = (o["pos_y"] - y) / o["scale"]
    level = "lower" if z is not None and "lower" in o and z < o["lower"] else "upper"
    return px, py, level
```

With pandas, the same arithmetic works on whole columns:

```python theme={null}
o = OVERVIEWS["mirage"]
states["px"] = (states.x - o["pos_x"]) / o["scale"]
states["py"] = (o["pos_y"] - states.y) / o["scale"]
```

## View direction

`yaw` is in degrees with 0 along world +x and 90 along world +y. Because the image's y axis points down, a view
direction drawn on the radar is:

```python theme={null}
import math
dx, dy = math.cos(math.radians(yaw)), -math.sin(math.radians(yaw))   # pixel offsets, per unit length
```

Radar images are not served by this API; they ship with the game.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.