Skip to main content
The engine extends the global Math object. No imports needed - just call Math.calcAngle(...) like you’d call Math.sin(...).
All angles are in radians unless stated otherwise. Convert with Math.toRadians(deg) and Math.toDegrees(rad).

Overview

Vectors & angles

Convert between directions and Euler angles, calculate aim angles.

Screen projection

Project 3D world positions onto your 2D screen.

Angle normalization

Clamp, normalize, and compare angles safely.

Interpolation

Lerp, smooth step, remap - smooth everything.

Vectors & angles

These three functions convert between world positions, direction vectors, and Euler angles (QAngle). They form the core of any aim or movement calculation.

calcAngle


Returns the angle you’d need to look from src directly at dst. This is the function you reach for first in any aim-related code.
The returned angle is not normalized. Pipe it through clampAngles before sending to the engine - it hard-caps pitch to [-89, 89] which the engine requires. Use normalizeAngles instead if you only need to wrap overflows (e.g. for angle comparisons or delta calculations).

angleVectors


Decomposes an Euler angle into three perpendicular direction vectors. “Where am I looking?” → forward. “What’s to my right?” → right.
You rarely need all three vectors. Destructure only what you use - const { forward } = ... is the most common pattern.
See also: vectorAngles - the inverse operation.

vectorAngles


The inverse of angleVectors - converts a direction vector back to an Euler angle.
See also: angleVectors - the inverse operation.

Screen projection

These functions bridge 3D world space and 2D screen space. You need them every time you draw something at a game object’s position.
worldToScreen projects a 3D point onto your monitor

A 3D world position projected to pixel coordinates on the screen.

worldToScreen


Projects a 3D position to pixel coordinates on your monitor. This is the function you’ll use 99% of the time for ESP and overlays.
Never skip the success check. Behind-camera positions project to random screen edges and cause wild flickering. This is the #1 ESP bug.
Full walkthrough: Drawing on screen builds a complete ESP overlay step by step using worldToScreen.

screenTransform


Same as worldToScreen but returns normalized device coordinates (-1 to 1) instead of pixel values. For custom projection math only.

Angle normalization

Engine angles can overflow or land outside expected ranges after math operations. These functions clean them up.

clampAngles


Hard-clamps each component to engine-safe bounds and returns the same object.
Mutates the original. Clone first if you need the raw value: const safe = Math.clampAngles({ ...rawAngle });

normalizeAngles


Wraps all components into [-180, 180] using modular arithmetic and returns the same object. Unlike clampAngles, 270° becomes −90°, not 180°.
Mutates the original, just like clampAngles. Clone first if you need the raw value: const wrapped = Math.normalizeAngles({ ...rawAngle });

calculateFOV


Returns the angular distance (in degrees) between two look-directions. Think of it as “how many degrees would I move my crosshair to reach this?” Returns number - 0 = perfectly aligned, 180 = opposite direction.

Interpolation & mapping

Five functions for smoothing, clamping, and remapping values. The building blocks for animations, health bars, opacity fades, and anything that transitions between two states.

clamp


Restricts a value to [min, max]. Below min → min. Above max → max.

lerp


Linear interpolation. t=0 → a, t=1 → b, t=0.5 → midpoint. Not clamped - t outside [0, 1] extrapolates past the endpoints.
lerp with a constant t each frame gives exponential decay - the object slows as it approaches the target. 0.1–0.3 feels smooth, 0.5+ feels snappy.

inverseLerp


The reverse of lerp: given a value in the [a, b] range, returns where it sits as a 0–1 factor.
Returns 0 if a === b (avoids division by zero). Keep this in mind when a and b come from game data that might collapse to a single value.

smoothStep


Like lerp but with easing - starts slow, speeds up, ends slow. Internally clamps t to [0, 1], then applies 3t² − 2t³.
lerp vs smoothStep vs lerp-per-frame:

remapVal


Maps a value from one range to another. The Swiss army knife for converting game values to visual properties. Does not clamp - wrap in clamp if you need bounded output.
Values outside the source range extrapolate: health 120 mapped from [0, 100] to [0, 255] gives 306. Always clamp when your data can exceed the expected range:
If srcMin === srcMax, the result is a division by zero. Guard against this when source bounds come from game data (e.g. maxHealth could be 0 for a newly spawned entity).

Putting it together

A typical overlay pipeline chains several interpolation functions. Here’s a complete example - an ESP name tag that fades and shrinks with distance:

Angle conversion