update vector3 docs

This commit is contained in:
Lera Elvoé 2025-02-14 01:21:27 +03:00
parent 28b22cc3cc
commit d766e4e34b
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc

View File

@ -2,6 +2,7 @@
--- @field x number --- @field x number
--- @field y number --- @field y number
--- @field z number --- @field z number
--- @alias vectorlike table | Vector3
local Vector3 = { local Vector3 = {
x = 0, x = 0,
y = 0, y = 0,
@ -26,8 +27,8 @@ local function is_weak_vector3(t)
end end
end end
---Returns a Vector3 multiplied either component-wise (if b is a weak table) or multiplies each component by b if b is a number. ---Returns a Vector3 multiplied either component-wise (if b is a weak Vector3) or multiplies each component by b if b is a number.
---@param b number|table|Vector3 ---@param b number|vectorlike
---@return Vector3 ---@return Vector3
function Vector3:__mul(b) function Vector3:__mul(b)
if type(b) == "number" then if type(b) == "number" then
@ -49,8 +50,8 @@ function Vector3:__mul(b)
return Vector3() return Vector3()
end end
---Returns a Vector3 divided either component-wise (if b is a weak table) or divides each component by b if b is a number. ---Returns a Vector3 divided either component-wise (if b is a weak Vector3) or divides each component by b if b is a number.
---@param b number|table|Vector3 ---@param b number|vectorlike
---@return Vector3 ---@return Vector3
function Vector3:__div(b) function Vector3:__div(b)
if type(b) == "number" then if type(b) == "number" then
@ -73,7 +74,7 @@ function Vector3:__div(b)
end end
---Returns a Vector3 with each component added together. ---Returns a Vector3 with each component added together.
---@param b table|Vector3 ---@param b vectorlike
---@return Vector3 ---@return Vector3
function Vector3:__add(b) function Vector3:__add(b)
if not is_weak_vector3(b) then if not is_weak_vector3(b) then
@ -88,8 +89,8 @@ function Vector3:__add(b)
} }
end end
---Returns a Vector3 with this vector's components subtracted from b. ---Returns a Vector3 with b's components subtracted from this vector.
---@param b table|Vector3 ---@param b vectorlike
---@return Vector3 ---@return Vector3
function Vector3:__sub(b) function Vector3:__sub(b)
if not is_weak_vector3(b) then if not is_weak_vector3(b) then
@ -104,7 +105,7 @@ function Vector3:__sub(b)
} }
end end
---Returns a new Vector3 with each component being a negation of this. ---Returns a new Vector3 with each component being a negation of this vector.
---@return Vector3 ---@return Vector3
function Vector3:__unm() function Vector3:__unm()
return Vector3{ return Vector3{
@ -140,8 +141,8 @@ end
Vector3.__index = Vector3 Vector3.__index = Vector3
--------API-------- --------API--------
function Vector3:length_squared() function Vector3:length_squared()
local x2 = self.x * self.x local x2 = self.x * self.x
local y2 = self.y * self.y local y2 = self.y * self.y
@ -163,7 +164,7 @@ function Vector3:normalized()
end end
---Returns the dot product of this vector with `with`. ---Returns the dot product of this vector with `with`.
---@param with table|Vector3 ---@param with vectorlike
---@return number ---@return number
function Vector3:dot(with) function Vector3:dot(with)
if not is_weak_vector3(with) then if not is_weak_vector3(with) then
@ -176,7 +177,7 @@ function Vector3:dot(with)
end end
---Returns the cross product of this vector with `with`. ---Returns the cross product of this vector with `with`.
---@param with table|Vector3 ---@param with vectorlike
---@return Vector3 ---@return Vector3
function Vector3:cross(with) function Vector3:cross(with)
if not is_weak_vector3(with) then if not is_weak_vector3(with) then
@ -192,7 +193,7 @@ function Vector3:cross(with)
end end
---Returns a vector rotated about `axis` by `angle` radians ---Returns a vector rotated about `axis` by `angle` radians
---@param axis table|Vector3 ---@param axis vectorlike
---@param angle number ---@param angle number
---@return Vector3 ---@return Vector3
function Vector3:rotated(axis, angle) function Vector3:rotated(axis, angle)