update vector3 docs
This commit is contained in:
parent
28b22cc3cc
commit
d766e4e34b
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user