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
0.
- Numbers
- Array
- Object
QAngle.zero
(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
sub
scale
factor. Returns a new QAngle.
div
divisor. Returns a new QAngle.
negate
Normalization
After math operations, components can overflow past[-180, 180].
These methods wrap them back.
normalize
[-180, 180] using modular arithmetic.
Mutates the original and returns this for chaining.
normalized
[-180, 180].
The original is untouched.
QAngle.normalizeAngle
[-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
right
up
Comparison
fovTo
other.
Equivalent to Math.calculateFOV but as an
instance method.
Returns
number - 0 = identical direction, 180 = opposite.
equals
false if other is not a
QAngle.
Utility
set
this.
clone
invalidate
NaN. Used as a sentinel value to mark an angle
as “not yet computed” or “invalid”. Mutates the original and returns
this.
length
√(pitch² + yaw² + roll²). Occasionally useful for measuring total
rotation magnitude.
lengthSqr
pitch² + yaw² + roll². Faster than length() when
you only need to compare magnitudes.
toArray
[pitch, yaw, roll] as a plain array.
toString
Common patterns
Real-world patterns that combine QAngle methods with the Math API.- Smooth aim
- Angle delta
- Direction offset
- Recoil compensation