From d766e4e34bcd495ea8b610c2850f063d3f6394a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 14 Feb 2025 01:21:27 +0300 Subject: [PATCH] update vector3 docs --- data/scripts/types/vector3.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/data/scripts/types/vector3.lua b/data/scripts/types/vector3.lua index a173e4b..46af0ab 100644 --- a/data/scripts/types/vector3.lua +++ b/data/scripts/types/vector3.lua @@ -2,6 +2,7 @@ --- @field x number --- @field y number --- @field z number +--- @alias vectorlike table | Vector3 local Vector3 = { x = 0, y = 0, @@ -26,8 +27,8 @@ local function is_weak_vector3(t) 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. ----@param b number|table|Vector3 +---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|vectorlike ---@return Vector3 function Vector3:__mul(b) if type(b) == "number" then @@ -49,8 +50,8 @@ function Vector3:__mul(b) return Vector3() 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. ----@param b number|table|Vector3 +---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|vectorlike ---@return Vector3 function Vector3:__div(b) if type(b) == "number" then @@ -73,7 +74,7 @@ function Vector3:__div(b) end ---Returns a Vector3 with each component added together. ----@param b table|Vector3 +---@param b vectorlike ---@return Vector3 function Vector3:__add(b) if not is_weak_vector3(b) then @@ -88,8 +89,8 @@ function Vector3:__add(b) } end ----Returns a Vector3 with this vector's components subtracted from b. ----@param b table|Vector3 +---Returns a Vector3 with b's components subtracted from this vector. +---@param b vectorlike ---@return Vector3 function Vector3:__sub(b) if not is_weak_vector3(b) then @@ -104,7 +105,7 @@ function Vector3:__sub(b) } 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 function Vector3:__unm() return Vector3{ @@ -140,8 +141,8 @@ end Vector3.__index = Vector3 - --------API-------- + function Vector3:length_squared() local x2 = self.x * self.x local y2 = self.y * self.y @@ -163,7 +164,7 @@ function Vector3:normalized() end ---Returns the dot product of this vector with `with`. ----@param with table|Vector3 +---@param with vectorlike ---@return number function Vector3:dot(with) if not is_weak_vector3(with) then @@ -176,7 +177,7 @@ function Vector3:dot(with) end ---Returns the cross product of this vector with `with`. ----@param with table|Vector3 +---@param with vectorlike ---@return Vector3 function Vector3:cross(with) if not is_weak_vector3(with) then @@ -192,7 +193,7 @@ function Vector3:cross(with) end ---Returns a vector rotated about `axis` by `angle` radians ----@param axis table|Vector3 +---@param axis vectorlike ---@param angle number ---@return Vector3 function Vector3:rotated(axis, angle)