Skip to content

Extended: QAngle

dounai2333 edited this page Jan 1, 2025 · 1 revision

Introduction

How to get this userdata:

Angle()
QAngle()

New variables

-- Using "Angle()" is same as "QAngle()".
local angle = Angle(1, 2, 3)
local pitch = angle.p -- angle.pitch also usable.
local yaw = angle.yaw
local roll = angle.r -- angle.roll also usable.

Math

The QAngle userdata now support calculating:

local angle1 = Angle(1, 2, 3)
local angle2 = Angle(4, 5, 6)

print(angle1 + angle2) -- Output: "5.000 7.000 9.000"
print(angle1 / angle2) -- Output: "0.250 0.400 0.500"
print(angle1 * angle2) -- Output: "4.000 10.000 18.000"
print(angle1 - angle2) -- Output: "-3.000 -3.000 -3.000"
print(-angle1) -- Output: "-1.000 -2.000 -3.000"
print(angle1 == angle2) -- Output: "false"

tostring

tostring(angle)

Format angle to a proper string "pitch yaw roll", with maximum 3 decimal places.

Add

angle:Add(angle)

Adds the values of the argument angle to the orignal angle.

This functions the same as angle1 + angle2 without creating a new angle object, skipping object construction and garbage collection.

angle: angle

Div

angle:Div(divisor)

Divides all values of the original angle by a scalar.

This functions the same as angle1 / num without creating a new angle object, skipping object construction and garbage collection.

divisor: number

Forward

angle:Forward()

Returns a normal vector facing in the direction that the angle points.

Return: vector

IsZero

angle:IsZero()

Returns whether the pitch, yaw and roll are 0 or not.

Return: true or false

Mul

angle:Mul(multiplier)

Multiplies a scalar to all the values of the orignal angle.

This functions the same as angle1 * num without creating a new angle object, skipping object construction and garbage collection.

multiplier: number

Normalize

angle:Normalize(z_alwayszero)

Normalizes the angles by applying a module with 360 to pitch, yaw and roll. If z_alwayszero is true, the roll will be set to 0.

z_alwayszero: bool

Sub

angle:Sub(angle)

Subtracts the values of the argument angle to the orignal angle.

This functions the same as angle1 - angle2 without creating a new angle object, skipping object construction and garbage collection.

angle: angle

Clone this wiki locally