Developer knowledge network · moderated exchange

UnreliableCode-Community

Community für Entwicklerforschung, Reverse Engineering und Codierung

Knowledge indexLive
4Categories
919Threads
2.8KBeiträge
Tutorial

Minimap Radar math: converting 3D World coordinates to 2D UI coordinates

matrix_math_guy
Math Specialist
MEMBER
Vertreter: 105
Beitrittsdatum: Aug 2018
Beiträge: 52
Danke: 41
Vor 1 Monaten · Jul 18, 2026 8:32 PM
#1

Formula for projecting 3D player coordinates onto a 2D rotating top-down radar:

CPP
Vector2 WorldToRadar(Vector3 localPos, Vector3 targetPos, float localYaw, float radarRadius, float zoomScale) {
    float dx = targetPos.x - localPos.x;
    float dy = targetPos.y - localPos.y;
    
    // Convert local yaw to radians
    float yawRad = localYaw * (3.14159265f / 180.0f);
    
    // Rotate vector by camera orientation
    float rotatedX = dx * cosf(yawRad) - dy * sinf(yawRad);
    float rotatedY = dx * sinf(yawRad) + dy * cosf(yawRad);
    
    // Scale distance
    float screenX = rotatedX * zoomScale;
    float screenY = rotatedY * zoomScale;
    
    // Clamp to radar circular boundary
    float dist = sqrtf(screenX * screenX + screenY * screenY);
    if (dist > radarRadius) {
        screenX = (screenX / dist) * radarRadius;
        screenY = (screenY / dist) * radarRadius;
    }
    return Vector2(screenX, screenY);
}
imgui_artisan
UI Designer
MEMBER
Vertreter: 202
Beitrittsdatum: Apr 2019
Beiträge: 54
Danke: 28
Vor 1 Monaten · Jul 19, 2026 3:18 AM
#2

Rendered with ImGui::GetWindowDrawList()->AddCircleFilled on an ImGui overlay window. Very responsive!

raycast_ryan
Ballistics Dev
MEMBER
Vertreter: 72
Beitrittsdatum: Sep 2019
Beiträge: 32
Danke: 16
Vor 1 Monaten · Jul 19, 2026 6:22 PM
#3

Clean 2D rotation matrix formula. Works for any top-down minimap projection.