mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-14 02:34:09 +02:00
sum any number of vectors
This commit is contained in:
parent
48c629c506
commit
f7018c4f67
@ -31,8 +31,13 @@ function Public.vector_length(vec)
|
||||
return Public.sqrt(vec.x * vec.x + vec.y * vec.y)
|
||||
end
|
||||
|
||||
function Public.vector_sum(vec1, vec2)
|
||||
return { x = vec1.x + vec2.x, y = vec1.y + vec2.y }
|
||||
function Public.vector_sum(...)
|
||||
local result = { x = 0, y = 0 }
|
||||
for _, vec in ipairs({ ... }) do
|
||||
result.x = result.x + vec.x
|
||||
result.y = result.y + vec.y
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function Public.vector_distance(vec1, vec2)
|
||||
|
Loading…
Reference in New Issue
Block a user