Skip to content

Library: Math

ᴏᴠ ━ ᴀɴɪꜱᴀ edited this page Dec 5, 2024 · 21 revisions

» Objective

While Lua provides a standard math module, it lacks certain advanced mathematical utilities and classes often required in complex applications. This library extends Lua's mathematical capabilities by introducing additional functionality.

» Importing

It's already imported by default whenever you import assetify. You need to declare the below globally only once:

loadstring(exports.assetify_library:import())()

» Modules

» APIs

ℹ️ Our extensions are designed with backward compatibility in mind; your existing code is expected to function as intended. Nonetheless, we recommend transitioning to newer syntax.

  • math.round() - shared

Rounds a floating point value by specified decimals.

local float: result = math.round(
   float: value,
   int: decimals --Optional: By default its 0 if left unspecified
)
  • math.percent() - shared

Retrieves specified percentage of the value.

local float: result = math.percent(
   float: value,
   float: percent
)
  • math.findDistance2D() - shared

Retrieves distance b/w two 2D-Points.

local float: result = math.findDistance2D(
   float: x1,
   float: y1,
   float: x2,
   float: y2
)
  • math.findDistance3D() - shared

Retrieves distance b/w two 3D-Points.

local float: result = math.findDistance3D(
   float: x1,
   float: y1,
   float: z1
   float: x2,
   float: y2,
   float: z2
)
  • math.findRotation2D() - shared

Generates nearest possible rotation b/w two 2D-Points.

local float: result = math.findRotation2D(
   float: x1,
   float: y1,
   float: x2,
   float: y2
)
  • math.findPointByRotation2D() - shared

Generates new coords of an existing 2D-Point after rotating it by specified distance & rotation angle.

local float: result = math.findPointByRotation2D(
   float: x,
   float: y,
   float: distance,
   float: rotation
)
Clone this wiki locally