Skip to main content
QAngle represents an Euler rotation as three components - pitch (up/down), yaw (left/right), and roll (tilt). Every view angle, aim calculation, and rotation in the engine uses this type.
All QAngle components are in degrees, not radians. The engine’s safe ranges are pitch [-89, 89], yaw [-180, 180], roll [-50, 50]. Use Math.clampAngles before sending angles to the engine.

Overview

Creating angles

Six constructor forms - numbers, arrays, objects, or zero.

Arithmetic

Add, subtract, scale, divide, negate - all return new instances.

Normalization

Wrap overflowed components back into valid ranges.

Direction vectors

Decompose into forward, right, and up vectors.

Comparison

FOV distance, equality checks.

Utility

Clone, set, invalidate, convert to array or string.

Components

All three are read/write number properties:

Creating angles

Six forms - use whichever reads best in your code.

Constructor


Creates a new QAngle. Missing components default to 0.
The object form is most readable when you only care about one or two components: new QAngle({ yaw: 90 }) is clearer than new QAngle(0, 90, 0).

QAngle.zero


Returns a new (0, 0, 0) angle. Equivalent to new QAngle() but reads better as a named factory.

Arithmetic

All arithmetic methods return a new QAngle - the original is never modified. This makes them safe to use in calculations without cloning first.

add


Component-wise addition. Returns a new QAngle.

sub


Component-wise subtraction. Returns a new QAngle.

scale


Multiplies all three components by factor. Returns a new QAngle.
Scaling can push components out of engine-safe ranges. Pipe the result through Math.clampAngles if you’re sending it to the engine.

div


Divides all three components by divisor. Returns a new QAngle.

negate


Flips the sign of all components. Returns a new QAngle.

Normalization

After math operations, components can overflow past [-180, 180]. These methods wrap them back.

normalize


Wraps all components into [-180, 180] using modular arithmetic. Mutates the original and returns this for chaining.
This mutates the original. If you need the raw value preserved, use normalized() instead, or clone first: const clean = angle.clone().normalize();

normalized


Returns a new QAngle with all components wrapped into [-180, 180]. The original is untouched.
normalize() vs normalized() - the naming follows a common pattern:Rule of thumb: bare verb mutates, past participle copies.

QAngle.normalizeAngle


Static utility - wraps a single angle value to [-180, 180]. Useful when you need to normalize one component without touching the others.

Direction vectors

Decompose the angle into perpendicular direction vectors. These are instance-method shortcuts for Math.angleVectors - same math, different syntax.

forward


Returns the forward direction vector - where this angle is pointing. This is the direction you’d trace a ray along.
angle.forward() is equivalent to Math.angleVectors(angle).forward - use whichever reads better. If you need multiple vectors at once, Math.angleVectors is more efficient (one decomposition vs three).

Returns the right direction vector - perpendicular to forward, pointing to the right side of the view.

up


Returns the up direction vector - perpendicular to both forward and right, pointing above the view.

Comparison

fovTo


Returns the angular distance in degrees between this angle and other. Equivalent to Math.calculateFOV but as an instance method. Returns number - 0 = identical direction, 180 = opposite.

equals


Exact component-wise equality. Returns false if other is not a QAngle.
This is exact float comparison. Two angles that look the same after normalization might not be equals() due to floating-point precision. For approximate comparison, use fovTo() with a small threshold instead.

Utility

set


Overwrites all components in place. Accepts the same forms as the constructor. Mutates the original and returns this.
The object form sets missing fields to 0, not to their previous value. angle.set({ yaw: 90 }) resets pitch and roll to 0. If you want to update only yaw, assign the property directly: angle.yaw = 90;

clone


Returns an independent deep copy. Modifying the clone does not affect the original.
Use clone() before mutating methods when you need to preserve the original: const safe = rawAngle.clone().normalize();

invalidate


Sets all components to NaN. Used as a sentinel value to mark an angle as “not yet computed” or “invalid”. Mutates the original and returns this.

length


Returns the Euclidean length of the angle treated as a 3D vector: √(pitch² + yaw² + roll²). Occasionally useful for measuring total rotation magnitude.

lengthSqr


Squared length - pitch² + yaw² + roll². Faster than length() when you only need to compare magnitudes.

toArray


Returns [pitch, yaw, roll] as a plain array.

toString


Returns a human-readable string with 3 decimal places.

Common patterns

Real-world patterns that combine QAngle methods with the Math API.