๐Ÿ”ขmath

Usage: math.{func}

This table extends the existing math table that is a part of Lua.

calc_angle๏ปฟ

Function

Calculates angles between 2 vectors.

Arguments

Name
Type
Description

src

Source vector.

dst

Destination vector.

Returns

Type
Description

Angles.

Example

local ang = math.calc_angle(vec1, vec2);

angle_normalize๏ปฟ

Function

Normalizes an angle.

Arguments

Name
Type
Description

angle

float

Input angle.

Returns

Type
Description

float

Normalized angle.

Example


approach_angles๏ปฟ

Function

Approaches an angle over time.

Arguments

Name
Type
Description

from

Start angle.

to

End angle.

speed

float

Approach speed.

Returns

Type
Description

Delta angle.

Example


edge_point๏ปฟ

Function

Returns a point on the edge of a box.

Arguments

Name
Type
Description

mins

Box mins.

maxs

Box maxs.

dir

Point direction (angle).

radius

float

Area radius.

Returns

Type
Description

Point.

Example


lerp๏ปฟ

Function

Linear interpolation.

Arguments

Name
Type
Description

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

Name
Type
Description

forward

Source vector.

up

Up vector. Defaults to nil.

Returns

Type
Description

Angles.

Example


world_to_screen๏ปฟ

Function

Transforms a point in the game world onto the viewport.

Arguments

Name
Type
Description

xyz

Point in the world.

round

bool

Whether should round the output. Defaults to true.

Returns

Type
Description

Point on the viewport.

Example


clamp๏ปฟ

Function

Clamps a value between min and max.

Arguments

Name
Type
Description

n

float

Value.

lower

float

Lowest value.

upper

float

Highest value.

Returns

Type
Description

float

Clamped value.

Example


remap_val๏ปฟ

Function

Maps the value from one range to another range.

Arguments

Name
Type
Description

val

float

Value.

a

float

Lowest source value.

b

float

Highest source value.

c

float

Lowest destination value.

d

float

Highest destination value.

Returns

Type
Description

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

Name
Type
Description

val

float

Value.

a

float

Lowest source value.

b

float

Highest source value.

c

float

Lowest destination value.

d

float

Highest destination value.

Returns

Type
Description

float

Mapped value.

Example


vec2๏ปฟ

Function

An alias to draw.vec2().

Example


vec3๏ปฟ

Function

An alias to vector().

Example

Last updated