Skip to content
Ruben edited this page Mar 17, 2024 · 3 revisions

Math

Extends the math library

Properties

euler

Type: number

Value: 2.718281828459045


Methods

interpolator

Args: (Num1: number Num2: number)

Returns: function(T: number) -> number

Creates an interpolator between 2 numbers


clamp

Args: (n: number min: number max: number)

Returns: number

Returns a clamped number between min and max, min cannot be above max.


lerp

Args: (Current: number Target: number T: number)

Returns: number

Returns a value between Current and Target based on T


rounddec

Args: (num: number dec: number)

Returns: number

Rounds of a number by decimal count (dec)


percent

Args: (n: number min: number max: number)

Returns number

Gets a perfect value between the min and max value


random2

Args: (min: number max: number)

Returns number

Generates a more percise and random number


Vector3

Vector3 library which supports math operators

Properties

one

Type: table(Vector3)

Value: (1, 1, 1)


zero

Type: table(Vector3)

Value: (0, 0, 0)


Methods

new

Args: (X: number? Y: number? Z: number?)

Returns: table(Vector3)

Creates a new Vector3 with a set X, Y and Z coordinate, default components are all 0 if not entered.


fromTDV

Args: (vec: table(Teardown.Vec))

Returns: table(Vector3)

Converts a teardown Vec into a Vector3.


random

Args: (min: table(Vector3) max: table(Vector3))

Returns: table(Vector3)

Creates a random Vector3 based on the min and max vectors


clamp

Args: (vector: table(Vector3) min: table(Vector3) or number max: table(Vector3) or number)

Returns: table(Vector3)

Clamps a Vector3 X,Y,Z components to the min and max components or numbers


abs

Args: (vector: table(Vector3))

Returns: table(Vector3)

Returns the absolute of X, Y and Z


Vector3.Properties

Supports +, -, -v, *, / and ^ with numbers and other Vector3's

X

Type: number

The X component of the Vector3


Y

Type: number

The Y component of the Vector3


Z

Type: number

The Z component of the Vector3


magnitude

Type: number

The magnitude / length of the Vector3


Magnitude

Type: number

The magnitude / length of the Vector3


unit

Type: table(Vector3)

A copy of the Vector3 but with a magnitude of 1


Unit

Type: table(Vector3)

A copy of the Vector3 but with a magnitude of 1


Vector3.Methods

Components

Args: (self: table(Vector3))

Returns: number number number

Returns the X, Y and Z components as a tuple

ToTDV

Args: (self: table(Vector3))

Returns: Teardown.Vec

Converts the Vector3 into a Teardown Vec