- [WIP] Implementant a Nemesio
This commit is contained in:
@@ -27,3 +27,10 @@ function util.luminance(r, g, b)
|
||||
return (0.2126*r + 0.7152*g + 0.0722*b)/255
|
||||
end
|
||||
|
||||
function util.normalize(v)
|
||||
local magnitud = math.sqrt(v.x * v.x + v.y * v.y)
|
||||
if magnitud == 0 then
|
||||
return {x = 0, y = 0} -- evita división por cero
|
||||
end
|
||||
return {x = v.x / magnitud, y = v.y / magnitud}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user