Math
This table extends the existing math
table that is a part of Lua.
calc_angle
Function
Calculates angles between 2 vectors.
Arguments
src
Source vector.
dst
Destination vector.
Returns
Angles.
Example
angle_normalize
Function
Normalizes an angle.
Arguments
angle
float
Input angle.
Returns
float
Normalized angle.
Example
approach_angles
Function
Approaches an angle over time.
Arguments
from
Start angle.
to
End angle.
speed
float
Approach speed.
Returns
Delta angle.
Example
edge_point
Function
Returns a point on the edge of a box.
Arguments
mins
Box mins.
maxs
Box maxs.
dir
Point direction (angle).
radius
float
Area radius.
Returns
Point.
Example
lerp
Function
Linear interpolation.
Arguments
t1
float
Start value.
t2
float
End value.
progress
float
Interpolation amount.
Returns
Type
Description
float
Interpolated value.
Example
vector_angles
Function
Calculates angles from a vector.
Arguments
forward
Source vector.
up
Up vector. Defaults to nil
.
Returns
Angles.
Example
world_to_screen
Function
Transforms a point in the game world onto the viewport.
Arguments
xyz
Point in the world.
round
bool
Whether should round the output. Defaults to true
.
Returns
Point on the viewport.
Example
clamp
Function
Clamps a value between min and max.
Arguments
n
float
Value.
lower
float
Lowest value.
upper
float
Highest value.
Returns
float
Clamped value.
Example
remap_val
Function
Maps the value from one range to another range.
Arguments
val
float
Value.
a
float
Lowest source value.
b
float
Highest source value.
c
float
Lowest destination value.
d
float
Highest destination value.
Returns
float
Mapped value.
Example
remap_val_clamped
Function
Maps the value from one range to another range. Additionally, clamps the value based on the source range.
Arguments
val
float
Value.
a
float
Lowest source value.
b
float
Highest source value.
c
float
Lowest destination value.
d
float
Highest destination value.
Returns
float
Mapped value.
Example
vec2
Function
An alias to draw.vec2()
.
Example
vec3
Function
An alias to vector()
.
Example
Last updated