Lua API
  • 🔎Overview
  • Getting started
    • 🚀Creating scripts
    • 📓Metadata
    • ☎ïļCallbacks
    • 🧠Examples
    • 🌐Useful resources
  • Documentation
    • ⚙ïļNamespaces
      • ðŸ–ĨïļGui
      • ✏ïļRender
      • 🏎ïļEngine
      • ðŸ”ĒMath
      • ⚙ïļUtilities
      • 🙎Entities
      • 📖Database
      • ðŸ–ąïļInput
      • 🌌Panorama
      • ðŸŠķMaterials
      • 📂Filesystem
      • 🗃ïļZip
    • ⚙ïļInstances
      • ⚙ïļGlobal Vars
      • ⚙ïļFatality
      • ⚙ïļGamerules
      • ⚙ïļServer
    • ⚙ïļDatatypes
      • ðŸ–Ĩïļcontrol
      • ðŸ–Ĩïļcheckbox
      • ðŸ–Ĩïļcombobox
      • ðŸ–Ĩïļcolor_picker
      • ðŸ–Ĩïļslider
      • ðŸ–Ĩïļtextbox
      • ðŸ–Ĩïļlist
      • ⚙ïļentity
      • ⚙ïļplayer_info
      • ⚙ïļweapon_info
      • ⚙ïļuser_cmd
      • ⚙ïļtrace_t
      • ⚙ïļvec3
      • ⚙ïļtimer
      • ⚙ïļcvar
      • ⚙ïļshot_info
      • ⚙ïļgame_event
      • ⚙ïļmaterial
      • ⚙ïļmaterial_var
      • ⚙ïļzip
      • ⚙ïļanimator
Powered by GitBook

ÂĐ 2025 - FATALITY

On this page
  • Variables
  • Functions
  • unpack
  • length
  • length2d
  • dist
  • dist2d
  • to2d
  • cross
  • normalize
  • dot
  • calc_angle
  1. Documentation
  2. Datatypes

vec3

math.vec3

Variables

  • x - number

  • y - number

  • z - number

Supported operators:

+, -, /, *

Functions

unpack

local vector = math.vec3(1, 2, 3)
local x, y, z = vector:unpack()

Returns:

x

number

y

number

z

number

length

local vector = math.vec3(1, 0, 0)
vector:length()

Returns:

number

length2d

local vector = math.vec3(1, 0, 0)
vector:length2d()

Returns:

number

dist

local vector = math.vec3(1, 0, 0)
local vector2 = math.vec3(5, 5, 5)
print(vector:dist(vector2))

other vector

math.vec3

vector to calculate distance

Returns:

distance

number

dist2d

local vector = math.vec3(1, 0, 0)
local vector2 = math.vec3(5, 5, 5)
print(vector:dist2d(vector2))

other vector

math.vec3

vector to calculate distance

Returns:

2-dimensional distance

number

to2d

local vector = math.vec3(1, 0, 0)
vector:to2d()

Returns:

the original vector with the z component set to 0

math.vec3

cross

local vector1 = math.vec3(1, 0, 0)
local vector2 = math.vec3(0, 1, 0)

local cross_product = vector1:cross(vector2)

other vector

math.vec3

vector to cross with

Returns:

math.vec3

normalize

local vector1 = math.vec3(50, 50, 100)
local vector_normalized = vector1:normalize()

Returns:

math.vec3

dot

local vector1 = math.vec3(50, 50, 100)
local dot_product = vector1:dot(math.vec3(1, 33, 7))

other vector

math.vec3

vector to calculate dot product with

Returns:

number

calc_angle

local vector1 = math.vec3(50, 50, 100)
local vector2 = math.vec3(1, 33, 7)
local angle = vector1:calc_angle(vector2)

other vector

math.vec3

vector to calculate angle with

Returns:

the angle between the two vectors

math.vec3

Previoustrace_tNexttimer

Last updated 2 years ago

the of the vector

the two dimensional of the vector

the of the two vectors

the

the two vectors

⚙ïļ
⚙ïļ
Value
Datatype
Value
Datatype
length
Value
Datatype
length
Parameter
Datatype
Description
Value
Datatype
Parameter
Datatype
Description
Value
Datatype
Value
Datatype
Parameter
Datatype
Description
Value
Datatype
cross product
Value
Datatype
vector normalized
Parameter
Datatype
Description
Value
Datatype
dot product
Parameter
Datatype
Description
Value
Datatype